I am trying to create library for websocket send.
public class SocketCls {
private WebSocketClient mWebSocketClient;
private void connectWebSocket(String url) throws URISyntaxException {
URI uri;
uri = new URI(url);
mWebSocketClient = new WebSocketClient(uri) {
@Override
public void onOpen(ServerHandshake serverHandshake) {
Log.i("Websocket", "Opened");
mWebSocketClient.send("Hello from " + Build.MANUFACTURER + " " + Build.MODEL);
}
@Override
public void onMessage(String s) {
final String message = s;
// Here i want to use callback
}
@Override
public void onClose(int i, String s, boolean b) {
Log.i("Websocket", "Closed " + s);
}
@Override
public void onError(Exception e) {
Log.i("Websocket", "Error " + e.getMessage());
}
};
mWebSocketClient.connect();
}
}
Normally i can achieve it but when i want it to put in separate package how to use callback ? please can anyone help me out this