private static <T> void sendInternal(final PooledByteBuffer pooledData, WebSocketFrameType type, final WebSocketChannel wsChannel, final WebSocketCallback<T> callback, T context, long timeoutmillis) { boolean closePooledData = true; try { StreamSinkFrameChannel channel = wsChannel.send(type); // TODO chunk data into some MTU-like thing to control packet size closePooledData = false; // channel.send takes ownership of pooledData so it no longer needs to be closed if(!channel.send(pooledData)) { throw WebSocketMessages.MESSAGES.unableToSendOnNewChannel(); } flushChannelAsync(wsChannel, callback, channel, context, timeoutmillis); } catch (IOException e) { if (callback != null) { callback.onError(wsChannel, context, e); } else { IoUtils.safeClose(wsChannel); } } finally { if ( closePooledData ) { pooledData.close(); } } }
private static <T> void sendInternal(final PooledByteBuffer pooledData, WebSocketFrameType type, final WebSocketChannel wsChannel, final WebSocketCallback<T> callback, T context, long timeoutmillis) { boolean closePooledData = true; try { StreamSinkFrameChannel channel = wsChannel.send(type); // TODO chunk data into some MTU-like thing to control packet size closePooledData = false; // channel.send takes ownership of pooledData so it no longer needs to be closed if(!channel.send(pooledData)) { throw WebSocketMessages.MESSAGES.unableToSendOnNewChannel(); } flushChannelAsync(wsChannel, callback, channel, context, timeoutmillis); } catch (IOException e) { if (callback != null) { callback.onError(wsChannel, context, e); } else { IoUtils.safeClose(wsChannel); } } finally { if ( closePooledData ) { pooledData.close(); } } }
private static <T> void sendInternal(final PooledByteBuffer pooledData, WebSocketFrameType type, final WebSocketChannel wsChannel, final WebSocketCallback<T> callback, T context, long timeoutmillis) { boolean closePooledData = true; try { StreamSinkFrameChannel channel = wsChannel.send(type); // TODO chunk data into some MTU-like thing to control packet size closePooledData = false; // channel.send takes ownership of pooledData so it no longer needs to be closed if(!channel.send(pooledData)) { throw WebSocketMessages.MESSAGES.unableToSendOnNewChannel(); } flushChannelAsync(wsChannel, callback, channel, context, timeoutmillis); } catch (IOException e) { if (callback != null) { callback.onError(wsChannel, context, e); } else { IoUtils.safeClose(wsChannel); } } finally { if ( closePooledData ) { pooledData.close(); } } }