fix generating Id

This commit is contained in:
nkzawa
2017-07-13 21:54:33 +09:00
parent 3f4890da14
commit f6bb7678b6

View File

@@ -163,11 +163,17 @@ public class Manager extends Emitter {
* Update `socket.id` of all sockets * Update `socket.id` of all sockets
*/ */
private void updateSocketIds() { private void updateSocketIds() {
for (Socket socket : this.nsps.values()) { for (Map.Entry<String, Socket> entry : this.nsps.entrySet()) {
socket.id = this.engine.id(); String nsp = entry.getKey();
Socket socket = entry.getValue();
socket.id = this.generateId(nsp);
} }
} }
private String generateId(String nsp) {
return ("/".equals(nsp) ? "" : (nsp + "#")) + this.engine.id();
}
public boolean reconnection() { public boolean reconnection() {
return this._reconnection; return this._reconnection;
} }
@@ -421,7 +427,7 @@ public class Manager extends Emitter {
* @param opts options. * @param opts options.
* @return a socket instance for the namespace. * @return a socket instance for the namespace.
*/ */
public Socket socket(String nsp, Options opts) { public Socket socket(final String nsp, Options opts) {
Socket socket = this.nsps.get(nsp); Socket socket = this.nsps.get(nsp);
if (socket == null) { if (socket == null) {
socket = new Socket(this, nsp, opts); socket = new Socket(this, nsp, opts);
@@ -440,7 +446,7 @@ public class Manager extends Emitter {
socket.on(Socket.EVENT_CONNECT, new Listener() { socket.on(Socket.EVENT_CONNECT, new Listener() {
@Override @Override
public void call(Object... objects) { public void call(Object... objects) {
s.id = self.engine.id(); s.id = self.generateId(nsp);
} }
}); });
} }