I’m trying to develop a websocket client for android here I leave my code but when I try to preview it throws error.
[javac] Path/to/Archive Line of “try {”: error: cannot find symbol
[javac] Path/to/Archive Line of “e.printStackTrace();”: error: cannot find symbol
[javac] Path/to/Archive Line of “@Override”: error: cannot find symbol
[javac] Path/to/Archive Line of “@}”: error: cannot find symbol
Please help me.
[Require("org.java-websocket","Java-WebSocket:1.3.0")]
[Foreign(Language.Java)]
static extern(Android) void ConnectWebsocket()
@{
URI uri;
try {
uri = new URI("ws://host:port");
} catch (URISyntaxException e) {
e.printStackTrace();
return;
}
mWebSocketClient = new WebSocketClient(uri) {
@Override
public void onOpen(ServerHandshake serverHandshake) {
debug_log("Websocket Opened");
}
@Override
public void onMessage(String s) {
final String message = s;
debug_log("Websocket" + message);
}
@Override
public void onClose(int i, String s, boolean b) {
debug_log("Websocket Closed " + s);
}
@Override
public void onError(Exception e) {
debug_log("Websocket Error " + e.getMessage());
}
};
mWebSocketClient.connect();
@}
This is the site that I use for reference https://www.varvet.com/blog/using-websockets-in-native-ios-and-android-apps/