Java 类com.squareup.okhttp.ws.WebSocketCall 实例源码

项目:weex-3d-map    文件:WXWebSocketManager.java   
public void connect(String url) {
  try {
    mHttpClient= (OkHttpClient) Class.forName("com.squareup.okhttp.OkHttpClient").newInstance();
  } catch (Exception e) {
    isSupportWebSocket =false;
    return;
  }
  mHttpClient.setConnectTimeout(10, TimeUnit.SECONDS);
  mHttpClient.setWriteTimeout(10, TimeUnit.SECONDS);
  // Disable timeouts for read
  mHttpClient.setReadTimeout(0, TimeUnit.MINUTES);

  Request request = new Request.Builder().url(url).build();
  WebSocketCall call = WebSocketCall.create(mHttpClient, request);
  call.enqueue(this);
}
项目:weex-3d-map    文件:WXWebSocketManager.java   
public void connect(String url) {
  try {
    mHttpClient= (OkHttpClient) Class.forName("com.squareup.okhttp.OkHttpClient").newInstance();
  } catch (Exception e) {
    isSupportWebSocket =false;
    return;
  }
  mHttpClient.setConnectTimeout(10, TimeUnit.SECONDS);
  mHttpClient.setWriteTimeout(10, TimeUnit.SECONDS);
  // Disable timeouts for read
  mHttpClient.setReadTimeout(0, TimeUnit.MINUTES);

  Request request = new Request.Builder().url(url).build();
  WebSocketCall call = WebSocketCall.create(mHttpClient, request);
  call.enqueue(this);
}
项目:Weex-TestDemo    文件:WXWebSocketManager.java   
public void connect(String url) {
  try {
    mHttpClient= (OkHttpClient) Class.forName("com.squareup.okhttp.OkHttpClient").newInstance();
  } catch (Exception e) {
    isSupportWebSocket =false;
    return;
  }
  mHttpClient.setConnectTimeout(10, TimeUnit.SECONDS);
  mHttpClient.setWriteTimeout(10, TimeUnit.SECONDS);
  // Disable timeouts for read
  mHttpClient.setReadTimeout(0, TimeUnit.MINUTES);

  Request request = new Request.Builder().url(url).build();
  WebSocketCall call = WebSocketCall.create(mHttpClient, request);
  call.enqueue(this);
}
项目:weex    文件:WXWebSocketManager.java   
public void connect(String url) {
  try {
    mHttpClient= (OkHttpClient) Class.forName("com.squareup.okhttp.OkHttpClient").newInstance();
  } catch (Exception e) {
    isSupportWebSocket =false;
    return;
  }
  mHttpClient.setConnectTimeout(10, TimeUnit.SECONDS);
  mHttpClient.setWriteTimeout(10, TimeUnit.SECONDS);
  // Disable timeouts for read
  mHttpClient.setReadTimeout(0, TimeUnit.MINUTES);

  Request request = new Request.Builder().url(url).build();
  WebSocketCall call = WebSocketCall.create(mHttpClient, request);
  call.enqueue(this);
}
项目:weex    文件:DebugSocketClient.java   
public void connect(String url, Callback callback) {
    if (mHttpClient != null) {
        throw new IllegalStateException("DebugSocketClient is already initialized.");
    }
    mConnectCallback = callback;
    mHttpClient = new OkHttpClient();
    mHttpClient.setConnectTimeout(30, TimeUnit.SECONDS);
    mHttpClient.setWriteTimeout(30, TimeUnit.SECONDS);
    // Disable timeouts for read
    mHttpClient.setReadTimeout(0, TimeUnit.MINUTES);

    if (!TextUtils.isEmpty(url)) {
        Request request = new Request.Builder().url(url).build();
        WebSocketCall call = WebSocketCall.create(mHttpClient, request);
        call.enqueue(this);
    }
}
项目:Rocket.Chat-android    文件:Meteor.java   
/**
 * Opens a connection to the server over websocket
 *
 * @param isReconnect whether this is a re-connect attempt or not
 */
public void openConnection(final boolean isReconnect) {

    if (isReconnect) {
        if (isConnected()) {
            connect(mSessionID);
            return;
        }
    }

    OkHttpClient client = new OkHttpClient();
    client.setConnectTimeout(1, TimeUnit.MINUTES);
    client.setReadTimeout(1, TimeUnit.MINUTES);
    client.setWriteTimeout(1, TimeUnit.MINUTES);
    HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
    loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BASIC);
    client.networkInterceptors().add(loggingInterceptor);

    Request request = new Request.Builder()
            .url(mServerUri)
            .build();
    WebSocketCall.create(client, request).enqueue(mWebSocketObserver);
}
项目:hawkular-android-client    文件:WebSocketClientGenerator.java   
/**
 * Creates a websocket that connects to the given URL.
 *
 * @param url where the websocket server is
 * @param headers headers to pass in the connect request
 * @return the websocket
 */
public WebSocketCall createWebSocketCall(String url, Map<String, String> headers) {
    String base64Credentials = buildBase64Credentials();

    Request.Builder requestBuilder = new Request.Builder()
            .url(url)
            .addHeader("Authorization", "Basic " + base64Credentials)
            .addHeader("Accept", "application/json");

    if (headers != null) {
        for (Map.Entry<String, String> header : headers.entrySet()) {
            requestBuilder.addHeader(header.getKey(), header.getValue());
        }
    }

    Request request = requestBuilder.build();
    WebSocketCall wsc = WebSocketCall.create(getHttpClient(), request);
    return wsc;
}
项目:weex-3d-map    文件:HotRefreshManager.java   
public boolean connect(String url) {
  OkHttpClient httpClient = new OkHttpClient();
  Request request = new Request.Builder().url(url).addHeader("sec-websocket-protocol", "echo-protocol").build();
  WebSocketCall.create(httpClient, request).enqueue(new WXWebSocketListener(url));

  return true;
}
项目:ReactNativeSignatureExample    文件:JSDebuggerWebSocketClient.java   
public void connect(String url, JSDebuggerCallback callback) {
  if (mHttpClient != null) {
    throw new IllegalStateException("JSDebuggerWebSocketClient is already initialized.");
  }
  mConnectCallback = callback;
  mHttpClient = new OkHttpClient();
  mHttpClient.setConnectTimeout(10, TimeUnit.SECONDS);
  mHttpClient.setWriteTimeout(10, TimeUnit.SECONDS);
  // Disable timeouts for read
  mHttpClient.setReadTimeout(0, TimeUnit.MINUTES);

  Request request = new Request.Builder().url(url).build();
  WebSocketCall call = WebSocketCall.create(mHttpClient, request);
  call.enqueue(this);
}
项目:react-native-ibeacon-android    文件:JSDebuggerWebSocketClient.java   
public void connect(String url, JSDebuggerCallback callback) {
  if (mHttpClient != null) {
    throw new IllegalStateException("JSDebuggerWebSocketClient is already initialized.");
  }
  mConnectCallback = callback;
  mHttpClient = new OkHttpClient();
  mHttpClient.setConnectTimeout(10, TimeUnit.SECONDS);
  mHttpClient.setWriteTimeout(10, TimeUnit.SECONDS);
  // Disable timeouts for read
  mHttpClient.setReadTimeout(0, TimeUnit.MINUTES);

  Request request = new Request.Builder().url(url).build();
  WebSocketCall call = WebSocketCall.create(mHttpClient, request);
  call.enqueue(this);
}
项目:weex-analyzer-android    文件:HotRefreshManager.java   
public boolean connect(String url) {
  OkHttpClient httpClient = new OkHttpClient();
  Request request = new Request.Builder().url(url).addHeader("sec-websocket-protocol", "echo-protocol").build();
  WebSocketCall.create(httpClient, request).enqueue(new WXWebSocketListener(url));

  return true;
}
项目:react-native-box-loaders    文件:JSDebuggerWebSocketClient.java   
public void connect(String url, JSDebuggerCallback callback) {
  if (mHttpClient != null) {
    throw new IllegalStateException("JSDebuggerWebSocketClient is already initialized.");
  }
  mConnectCallback = callback;
  mHttpClient = new OkHttpClient();
  mHttpClient.setConnectTimeout(10, TimeUnit.SECONDS);
  mHttpClient.setWriteTimeout(10, TimeUnit.SECONDS);
  // Disable timeouts for read
  mHttpClient.setReadTimeout(0, TimeUnit.MINUTES);

  Request request = new Request.Builder().url(url).build();
  WebSocketCall call = WebSocketCall.create(mHttpClient, request);
  call.enqueue(this);
}
项目:weex-3d-map    文件:HotRefreshManager.java   
public boolean connect(String url) {
  OkHttpClient httpClient = new OkHttpClient();
  Request request = new Request.Builder().url(url).addHeader("sec-websocket-protocol", "echo-protocol").build();
  WebSocketCall.create(httpClient, request).enqueue(new WXWebSocketListener(url));

  return true;
}
项目:Weex-TestDemo    文件:HotRefreshManager.java   
public boolean connect(String url) {
  OkHttpClient httpClient = new OkHttpClient();
  Request request = new Request.Builder().url(url).addHeader("sec-websocket-protocol", "echo-protocol").build();
  WebSocketCall.create(httpClient, request).enqueue(new WXWebSocketListener(url));

  return true;
}
项目:weex    文件:HotRefreshManager.java   
public boolean connect(String url) {
  OkHttpClient httpClient = new OkHttpClient();
  Request request = new Request.Builder().url(url).addHeader("sec-websocket-protocol", "echo-protocol").build();
  WebSocketCall.create(httpClient, request).enqueue(new WXWebSocketListener(url));

  return true;
}
项目:appstax-java    文件:AxClient.java   
protected void socket(String path, WebSocketListener listener) {
    Request.Builder req = new Request.Builder();
    setWsPath(req, path);
    setKeys(req);
    setBody(req, Method.GET, null);
    WebSocketCall.create(ok, req.build()).enqueue(listener);
}
项目:kubernetes-client    文件:WebSockets.java   
private static Listener streamRequest(Request request, ApiClient client, io.kubernetes.client.util.WebSockets.SocketListener listener) {
    WebSocketCall webSocketCall = WebSocketCall.create(client.getHttpClient(), request);
    Listener listener1 = new Listener(listener, webSocketCall);
    webSocketCall.enqueue(listener1);
    return listener1;
}
项目:kubernetes-client    文件:WebSockets.java   
public Listener(io.kubernetes.client.util.WebSockets.SocketListener listener, WebSocketCall webSocketCall) {
    this.listener = listener;
    this.webSocketCall = webSocketCall;
}
项目:actioncable-client-java    文件:Connection.java   
private void doOpen() {
    state = State.CONNECTING;

    OkHttpClient client;
    if (options.okHttpClientFactory != null) {
        client = options.okHttpClientFactory.createOkHttpClient();
    } else {
        client = new OkHttpClient();
    }

    if (options.sslContext != null) {
        final SSLSocketFactory factory = options.sslContext.getSocketFactory();
        client.setSslSocketFactory(factory);
    }

    if (options.hostnameVerifier != null) {
        client.setHostnameVerifier(options.hostnameVerifier);
    }

    if (options.cookieHandler != null) {
        client.setCookieHandler(options.cookieHandler);
    }

    String url = uri.toString();
    if (options.query != null) {
        url = url + "?" + QueryStringUtils.encode(options.query);
    }

    final Request.Builder builder = new Request.Builder().url(url);

    if (options.headers != null) {
        for (Map.Entry<String, String> entry : options.headers.entrySet()) {
            builder.addHeader(entry.getKey(), entry.getValue());
        }
    }

    final Request request = builder.build();

    final WebSocketCall webSocketCall = WebSocketCall.create(client, request);
    webSocketCall.enqueue(webSocketListener);

    client.getDispatcher().getExecutorService().shutdown();
}