create a new connection when path is the same

This commit is contained in:
nkzawa
2016-01-31 17:33:28 +09:00
parent d538a9d117
commit f7810c19d3
4 changed files with 38 additions and 4 deletions

View File

@@ -64,13 +64,17 @@ public class IO {
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
String id = Url.extractId(parsed);
String path = parsed.getPath();
boolean sameNamespace = managers.containsKey(id)
&& managers.get(id).nsps.containsKey(path);
boolean newConnection = opts.forceNew || !opts.multiplex || sameNamespace;
Manager io;
if (opts.forceNew || !opts.multiplex) {
if (newConnection) {
logger.fine(String.format("ignoring socket cache for %s", source));
io = new Manager(source, opts);
} else {
String id = Url.extractId(parsed);
if (!managers.containsKey(id)) {
logger.fine(String.format("new io instance for %s", source));
managers.putIfAbsent(id, new Manager(source, opts));

View File

@@ -96,7 +96,7 @@ public class Manager extends Emitter {
/**
* This HashMap can be accessed from outside of EventThread.
*/
private ConcurrentHashMap<String, Socket> nsps;
/*package*/ ConcurrentHashMap<String, Socket> nsps;
public Manager() {