@Override public void onResponse(Call call, Response response) { StreamAllocation streamAllocation = Internal.instance.streamAllocation(call); try { checkResponse(response); } catch (ProtocolException e) { failWebSocket(e, response); closeQuietly(response); streamAllocation.streamFailed(e); return; } // Promote the HTTP streams into web socket streams. streamAllocation.noNewStreams(); // Prevent connection pooling! Streams streams = streamAllocation.connection().newWebSocketStreams(streamAllocation); // Process all web socket messages. try { String name = "OkHttp WebSocket " + request.url().redact(); initReaderAndWriter(name, streams); listener.onOpen(RealWebSocket.this, response); streamAllocation.connection().socket().setSoTimeout(0); loopReader(); } catch (Exception e) { failWebSocket(e, null); } }
@Override public void onResponse(Call call, Response response) { StreamAllocation streamAllocation = Internal.instance.streamAllocation(call); try { checkResponse(response); } catch (ProtocolException e) { failWebSocket(e, response); closeQuietly(response); streamAllocation.streamFailed(e); return; } // Promote the HTTP streams into web socket streams. streamAllocation.noNewStreams(); // Prevent connection pooling! Streams streams = streamAllocation.connection().newWebSocketStreams(streamAllocation); // Process all web socket messages. try { String name = "OkHttp WebSocket " + request.url().redact(); initReaderAndWriter(name, streams); listener.onOpen(RealWebSocket.this, response); streamAllocation.connection().socket().setSoTimeout(0); loopReader(); } catch (Exception e) { failWebSocket(e, null); } }
@Override public void onResponse(Call call, Response response) { try { checkResponse(response); } catch (ProtocolException e) { failWebSocket(e, response); closeQuietly(response); return; } // Promote the HTTP streams into web socket streams. StreamAllocation streamAllocation = Internal.instance.streamAllocation(call); streamAllocation.noNewStreams(); // Prevent connection pooling! Streams streams = streamAllocation.connection().newWebSocketStreams(streamAllocation); // Process all web socket messages. try { listener.onOpen(RealWebSocket.this, response); String name = "OkHttp WebSocket " + request.url().redact(); initReaderAndWriter(name, streams); streamAllocation.connection().socket().setSoTimeout(0); loopReader(); } catch (Exception e) { failWebSocket(e, null); } }
@Override public void onResponse(Call call, Response response) { try { checkResponse(response); } catch (ProtocolException e) { failWebSocket(e, response); closeQuietly(response); return; } // Promote the HTTP streams into web socket streams. StreamAllocation streamAllocation = Internal.instance.streamAllocation(call); streamAllocation.noNewStreams(); // Prevent connection pooling! Streams streams = streamAllocation.connection().newWebSocketStreams(streamAllocation); // Process all web socket messages. try { listener.onOpen(RealWebSocket.this, response); String name = "OkHttp WebSocket " + request.url().redact(); initReaderAndWriter(name, pingIntervalMillis, streams); streamAllocation.connection().socket().setSoTimeout(0); loopReader(); } catch (Exception e) { failWebSocket(e, null); } }