This commit is contained in:
地平线
2015-06-29 12:50:34 +08:00
parent b6b85d57b4
commit 530e625508

View File

@@ -143,13 +143,14 @@ public class WebSocketRunner implements Runnable {
public void sendMessage(WebSocketPacket packet) { public void sendMessage(WebSocketPacket packet) {
if (packet == null || closed) return; if (packet == null || closed) return;
final boolean debug = this.coder.debugable;
//System.out.println("推送消息"); //System.out.println("推送消息");
final byte[] bytes = coder.encode(packet); final byte[] bytes = coder.encode(packet);
if (debug) context.getLogger().log(Level.FINEST, "send web socket message's length = " + bytes.length);
if (writing.getAndSet(true)) { if (writing.getAndSet(true)) {
queue.add(bytes); queue.add(bytes);
return; return;
} }
final boolean debug = this.coder.debugable;
if (writeBuffer == null) return; if (writeBuffer == null) return;
ByteBuffer sendBuffer = null; ByteBuffer sendBuffer = null;
if (bytes.length <= writeBuffer.capacity()) { if (bytes.length <= writeBuffer.capacity()) {