send query on connecti

This commit is contained in:
nkzawa
2017-07-12 01:09:11 +09:00
parent 2925cdb4e3
commit 4811368854
5 changed files with 47 additions and 5 deletions

View File

@@ -418,12 +418,13 @@ public class Manager extends Emitter {
* Initializes {@link Socket} instances for each namespaces.
*
* @param nsp namespace.
* @param opts options.
* @return a socket instance for the namespace.
*/
public Socket socket(String nsp) {
public Socket socket(String nsp, Options opts) {
Socket socket = this.nsps.get(nsp);
if (socket == null) {
socket = new Socket(this, nsp);
socket = new Socket(this, nsp, opts);
Socket _socket = this.nsps.putIfAbsent(nsp, socket);
if (_socket != null) {
socket = _socket;
@@ -447,6 +448,10 @@ public class Manager extends Emitter {
return socket;
}
public Socket socket(String nsp) {
return socket(nsp, null);
}
/*package*/ void destroy(Socket socket) {
this.connecting.remove(socket);
if (!this.connecting.isEmpty()) return;
@@ -458,6 +463,10 @@ public class Manager extends Emitter {
logger.fine(String.format("writing packet %s", packet));
final Manager self = this;
if (packet.query != null && !packet.query.isEmpty() && packet.type == Parser.CONNECT) {
packet.nsp += "?" + packet.query;
}
if (!self.encoding) {
self.encoding = true;
this.encoder.encode(packet, new Parser.Encoder.Callback() {