simplify custom encoder/decoder
This commit is contained in:
@@ -149,10 +149,8 @@ public class Manager extends Emitter {
|
||||
this.uri = uri;
|
||||
this.encoding = false;
|
||||
this.packetBuffer = new ArrayList<Packet>();
|
||||
|
||||
Parser parser = opts.parser != null ? opts.parser : new IOParser();
|
||||
this.encoder = parser.getEncoder();
|
||||
this.decoder = parser.getDecoder();
|
||||
this.encoder = opts.encoder != null ? opts.encoder : new IOParser.Encoder();
|
||||
this.decoder = opts.decoder != null ? opts.decoder : new IOParser.Decoder();
|
||||
}
|
||||
|
||||
private void emitAll(String event, Object... args) {
|
||||
@@ -634,7 +632,8 @@ public class Manager extends Emitter {
|
||||
public long reconnectionDelay;
|
||||
public long reconnectionDelayMax;
|
||||
public double randomizationFactor;
|
||||
public Parser parser;
|
||||
public Parser.Encoder encoder;
|
||||
public Parser.Decoder decoder;
|
||||
|
||||
/**
|
||||
* Connection timeout (ms). Set -1 to disable.
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package io.socket.parser;
|
||||
|
||||
import io.socket.client.IO;
|
||||
import io.socket.hasbinary.HasBinary;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONTokener;
|
||||
@@ -18,17 +19,7 @@ final public class IOParser implements Parser {
|
||||
return new Packet<String>(ERROR, "parser error");
|
||||
}
|
||||
|
||||
public IOParser() {}
|
||||
|
||||
@Override
|
||||
public Parser.Encoder getEncoder () {
|
||||
return new Encoder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Parser.Decoder getDecoder () {
|
||||
return new Decoder();
|
||||
}
|
||||
private IOParser() {}
|
||||
|
||||
final public static class Encoder implements Parser.Encoder {
|
||||
|
||||
|
||||
@@ -63,10 +63,6 @@ public interface Parser {
|
||||
"BINARY_ACK"
|
||||
};
|
||||
|
||||
public Encoder getEncoder();
|
||||
|
||||
public Decoder getDecoder();
|
||||
|
||||
public static interface Encoder {
|
||||
|
||||
public void encode(Packet obj, Callback callback);
|
||||
|
||||
Reference in New Issue
Block a user