@@ -163,11 +163,17 @@ private void emitAll(String event, Object... args) {
163163 * Update `socket.id` of all sockets
164164 */
165165 private void updateSocketIds () {
166- for (Socket socket : this .nsps .values ()) {
167- socket .id = this .engine .id ();
166+ for (Map .Entry <String , Socket > entry : this .nsps .entrySet ()) {
167+ String nsp = entry .getKey ();
168+ Socket socket = entry .getValue ();
169+ socket .id = this .generateId (nsp );
168170 }
169171 }
170172
173+ private String generateId (String nsp ) {
174+ return ("/" .equals (nsp ) ? "" : (nsp + "#" )) + this .engine .id ();
175+ }
176+
171177 public boolean reconnection () {
172178 return this ._reconnection ;
173179 }
@@ -421,7 +427,7 @@ private void onerror(Exception err) {
421427 * @param opts options.
422428 * @return a socket instance for the namespace.
423429 */
424- public Socket socket (String nsp , Options opts ) {
430+ public Socket socket (final String nsp , Options opts ) {
425431 Socket socket = this .nsps .get (nsp );
426432 if (socket == null ) {
427433 socket = new Socket (this , nsp , opts );
@@ -440,7 +446,7 @@ public void call(Object... args) {
440446 socket .on (Socket .EVENT_CONNECT , new Listener () {
441447 @ Override
442448 public void call (Object ... objects ) {
443- s .id = self .engine . id ( );
449+ s .id = self .generateId ( nsp );
444450 }
445451 });
446452 }
0 commit comments