10485a.patch
| new/src/com/goldencode/p2j/ui/client/driver/web/PushMessagesWorker.java 2025-09-08 10:27:02 +0000 | ||
|---|---|---|
| 109 | 109 |
/** The session guard object */ |
| 110 | 110 |
private final Object sessionGuard = new Object(); |
| 111 | 111 |
|
| 112 |
/** TODO */ |
|
| 113 |
private final ReentrantLock sendLock; |
|
| 114 |
|
|
| 112 | 115 |
/** The session state */ |
| 113 | 116 |
private boolean sessionInvalid = true; |
| 114 | 117 |
|
| 118 |
// /** |
|
| 119 |
// * The default constructor. |
|
| 120 |
// */ |
|
| 121 |
// public PushMessagesWorker() |
|
| 122 |
// {
|
|
| 123 |
// this.setName("pushworker");
|
|
| 124 |
// |
|
| 125 |
// this.start(); |
|
| 126 |
// } |
|
| 127 |
|
|
| 115 | 128 |
/** |
| 116 | 129 |
* The default constructor. |
| 117 | 130 |
*/ |
| 118 |
public PushMessagesWorker() |
|
| 131 |
public PushMessagesWorker(ReentrantLock sendLock)
|
|
| 119 | 132 |
{
|
| 133 |
this.sendLock = sendLock; |
|
| 120 | 134 |
this.setName("pushworker");
|
| 121 |
|
|
| 122 | 135 |
this.start(); |
| 123 | 136 |
} |
| 124 | 137 | |
| ... | ... | |
| 287 | 300 |
// test message type |
| 288 | 301 |
if (message instanceof ByteBuffer) |
| 289 | 302 |
{
|
| 290 |
remote.sendBytes((ByteBuffer) message); |
|
| 303 |
try |
|
| 304 |
{
|
|
| 305 |
sendLock.lock(); |
|
| 306 |
remote.sendBytes((ByteBuffer) message); |
|
| 307 |
} |
|
| 308 |
finally |
|
| 309 |
{
|
|
| 310 |
sendLock.unlock(); |
|
| 311 |
} |
|
| 291 | 312 |
} |
| 292 | 313 |
else if (message instanceof String) |
| 293 | 314 |
{
|
| new/src/com/goldencode/p2j/ui/client/driver/web/WebClientProtocol.java 2025-09-08 10:25:45 +0000 | ||
|---|---|---|
| 108 | 108 |
import java.util.*; |
| 109 | 109 |
import java.util.concurrent.*; |
| 110 | 110 |
import java.util.concurrent.atomic.*; |
| 111 |
import java.util.concurrent.locks.ReentrantLock; |
|
| 111 | 112 |
import java.util.logging.*; |
| 112 | 113 | |
| 113 | 114 |
import com.fasterxml.jackson.databind.*; |
| ... | ... | |
| 271 | 272 |
/** The new created temporary file extension */ |
| 272 | 273 |
private static final String TMP_FILE_EXT = ".tmp"; |
| 273 | 274 |
|
| 275 |
/** TODO */ |
|
| 276 |
private static final ReentrantLock sendLock = new ReentrantLock(); |
|
| 277 |
|
|
| 274 | 278 |
/** Web socket timeout. */ |
| 275 | 279 |
private final long timeout; |
| 276 | 280 |
|
| ... | ... | |
| 729 | 733 |
{
|
| 730 | 734 |
if (session.isOpen()) |
| 731 | 735 |
{
|
| 732 |
session.getRemote().sendBytes(ByteBuffer.wrap(message)); |
|
| 736 |
try |
|
| 737 |
{
|
|
| 738 |
sendLock.lock(); |
|
| 739 |
session.getRemote().sendBytes(ByteBuffer.wrap(message)); |
|
| 740 |
} |
|
| 741 |
finally |
|
| 742 |
{
|
|
| 743 |
sendLock.unlock(); |
|
| 744 |
} |
|
| 733 | 745 |
} |
| 734 | 746 |
} |
| 735 | 747 |
catch (IOException ex) |
| ... | ... | |
| 1427 | 1439 |
{
|
| 1428 | 1440 |
if (pushWorker == null) |
| 1429 | 1441 |
{
|
| 1430 |
pushWorker = new PushMessagesWorker(); |
|
| 1442 |
pushWorker = new PushMessagesWorker(sendLock);
|
|
| 1431 | 1443 |
} |
| 1432 | 1444 |
pushWorker.setCurrentSession(session); |
| 1433 | 1445 |
} |