You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Java 1.7, the following code produces a compile-time error:
final IOSocket socket = new IOSocket("http://localhost:4000", new MessageCallback() {
@Override public void onConnect() {
try {
socket.emit("start_session", ....
The error is: "The local variable socket may not have been initialized".
A possible solution is to create the callback, not in the constructor but only after the constructor. A small addition is required in IOSocket to support this:
public IOSocket(String address){
webSocketAddress = address;
this.callback = null;
}
public IOSocket setCallback(MessageCallback callback){
this.callback = callback;
return this;
}
The text was updated successfully, but these errors were encountered:
In Java 1.7, the following code produces a compile-time error:
The error is: "The local variable socket may not have been initialized".
A possible solution is to create the callback, not in the constructor but only after the constructor. A small addition is required in IOSocket to support this:
The text was updated successfully, but these errors were encountered: