1616import org .json .JSONException ;
1717import org .json .JSONObject ;
1818
19- import android .os .Bundle ;
2019import android .os .Handler ;
2120import android .os .Looper ;
2221
3534import com .koushikdutta .async .callback .RequestCallback ;
3635import com .koushikdutta .async .http .AsyncHttpClientMiddleware .OnRequestCompleteData ;
3736import com .koushikdutta .async .http .libcore .RawHeaders ;
38- import com .koushikdutta .async .http .libcore .ResponseHeaders ;
3937import com .koushikdutta .async .stream .OutputStreamDataCallback ;
4038
4139public class AsyncHttpClient {
@@ -481,9 +479,9 @@ public static interface WebSocketConnectCallback {
481479 public void onCompleted (Exception ex , WebSocket webSocket );
482480 }
483481
484- public void websocket (final AsyncHttpRequest req , String protocol , final WebSocketConnectCallback callback ) {
482+ public Cancelable websocket (final AsyncHttpRequest req , String protocol , final WebSocketConnectCallback callback ) {
485483 WebSocketImpl .addWebSocketUpgradeHeaders (req .getHeaders ().getHeaders (), protocol );
486- execute (req , new HttpConnectCallback () {
484+ return execute (req , new HttpConnectCallback () {
487485 @ Override
488486 public void onConnectCompleted (Exception ex , AsyncHttpResponse response ) {
489487 if (ex != null ) {
@@ -498,9 +496,9 @@ public void onConnectCompleted(Exception ex, AsyncHttpResponse response) {
498496 });
499497 }
500498
501- public void websocket (String uri , String protocol , final WebSocketConnectCallback callback ) {
499+ public Cancelable websocket (String uri , String protocol , final WebSocketConnectCallback callback ) {
502500 final AsyncHttpGet get = new AsyncHttpGet (uri );
503- websocket (get , protocol , callback );
501+ return websocket (get , protocol , callback );
504502 }
505503
506504 AsyncServer getServer () {
0 commit comments