This commit is contained in:
wentch
2015-12-29 17:07:12 +08:00
parent 20d5fff717
commit 5b0ada9cd4
3 changed files with 13 additions and 4 deletions

View File

@@ -257,12 +257,16 @@ public abstract class WebSocket {
private int sendMessage(Serializable groupid, boolean recent, String text, boolean last) {
if (_engine.node == null) return RETCODE_NODESERVICE_NULL;
return _engine.node.sendMessage(groupid, recent, text, last);
int rs = _engine.node.sendMessage(groupid, recent, text, last);
if(_engine.finest) _engine.logger.finest("groupid:" + groupid + " websocket "+(recent ? "recent " : "") + "send result is " + rs + " on " + this + " by message(" + text + ")");
return rs;
}
private int sendMessage(Serializable groupid, boolean recent, byte[] data, boolean last) {
if (_engine.node == null) return RETCODE_NODESERVICE_NULL;
return _engine.node.sendMessage(groupid, recent, data, last);
int rs = _engine.node.sendMessage(groupid, recent, data, last);
if(_engine.finest) _engine.logger.finest("groupid:" + groupid + " websocket "+(recent ? "recent " : "") + "send result is " + rs + " on " + this + " by message(byte[" + data.length + "])");
return rs;
}
/**
@@ -426,4 +430,9 @@ public abstract class WebSocket {
public void onClose(int code, String reason) {
}
@Override
public String toString() {
return "ws" + Objects.hashCode(this) + "@" + _remoteAddr;
}
}

View File

@@ -69,7 +69,7 @@ public final class WebSocketEngine {
containers.putIfAbsent(socket._groupid, group);
}
group.add(socket);
if (node != null) node.connect(socket._groupid, engineid);
if (node != null) node.connect(socket._groupid, engineid, socket.toString());
}
void remove(WebSocket socket) {

View File

@@ -102,7 +102,7 @@ public abstract class WebSocketNode {
return map;
}
public final void connect(Serializable groupid, String engineid) {
public final void connect(Serializable groupid, String engineid, String wsinfo) {
if (finest) logger.finest(localSncpAddress + " receive websocket connect event (" + groupid + " on " + engineid + ").");
Set<String> engineids = localNodes.get(groupid);
if (engineids == null) {