Search in sources :

Example 1 with WebSocketRequestCallback

use of com.koushikdutta.async.http.server.AsyncHttpServer.WebSocketRequestCallback in project AndroidAsync by koush.

the class WebSocketTests method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    httpServer = new AsyncHttpServer();
    httpServer.setErrorCallback(new CompletedCallback() {

        @Override
        public void onCompleted(Exception ex) {
            fail();
        }
    });
    httpServer.listen(AsyncServer.getDefault(), 5000);
    httpServer.websocket("/ws", new WebSocketRequestCallback() {

        @Override
        public void onConnected(final WebSocket webSocket, AsyncHttpServerRequest request) {
            webSocket.setStringCallback(new StringCallback() {

                @Override
                public void onStringAvailable(String s) {
                    webSocket.send(s);
                }
            });
        }
    });
}
Also used : CompletedCallback(com.koushikdutta.async.callback.CompletedCallback) WebSocketRequestCallback(com.koushikdutta.async.http.server.AsyncHttpServer.WebSocketRequestCallback) AsyncHttpServerRequest(com.koushikdutta.async.http.server.AsyncHttpServerRequest) AsyncHttpServer(com.koushikdutta.async.http.server.AsyncHttpServer) StringCallback(com.koushikdutta.async.http.WebSocket.StringCallback) WebSocket(com.koushikdutta.async.http.WebSocket)

Aggregations

CompletedCallback (com.koushikdutta.async.callback.CompletedCallback)1 WebSocket (com.koushikdutta.async.http.WebSocket)1 StringCallback (com.koushikdutta.async.http.WebSocket.StringCallback)1 AsyncHttpServer (com.koushikdutta.async.http.server.AsyncHttpServer)1 WebSocketRequestCallback (com.koushikdutta.async.http.server.AsyncHttpServer.WebSocketRequestCallback)1 AsyncHttpServerRequest (com.koushikdutta.async.http.server.AsyncHttpServerRequest)1