@Override public XnioIoThread getIoThread() { return delegate.getIoThread(); }
public XnioIoThread getWriteThread() { return channel.getIoThread(); }
public XnioIoThread getIoThread() { return delegate.getIoThread(); }
public XnioIoThread getIoThread() { return delegate.getIoThread(); }
/** * execute a graceful shutdown once all data has been sent */ public void shutdown() { if (open == 0 || shutdown) { return; } shutdown = true; sink.getIoThread().execute(new Runnable() { @Override public void run() { synchronized (ServerSentEventConnection.this) { if (queue.isEmpty() && pooled == null) { exchange.endExchange(); } } } }); }
/** * Sends the 'retry' message to the client, instructing it how long to wait before attempting a reconnect. * * @param retry The retry time in milliseconds * @param callback The callback that is notified on success or failure */ public synchronized void sendRetry(long retry, EventCallback callback) { if (open == 0 || shutdown) { if (callback != null) { callback.failed(this, null, null, null, new ClosedChannelException()); } return; } queue.add(new SSEData(retry, callback)); sink.getIoThread().execute(new Runnable() { @Override public void run() { synchronized (ServerSentEventConnection.this) { if (pooled == null) { fillBuffer(); writeListener.handleEvent(sink); } } } }); }
/** * Sends an event to the remote client * * @param data The event data * @param event The event name * @param id The event ID * @param callback A callback that is notified on Success or failure */ public synchronized void send(String data, String event, String id, EventCallback callback) { if (open == 0 || shutdown) { if (callback != null) { callback.failed(this, data, event, id, new ClosedChannelException()); } return; } queue.add(new SSEData(event, data, id, callback)); sink.getIoThread().execute(new Runnable() { @Override public void run() { synchronized (ServerSentEventConnection.this) { if (pooled == null) { fillBuffer(); writeListener.handleEvent(sink); } } } }); }
this.timerKey.remove(); this.timerKey = sink.getIoThread().executeAtInterval(new Runnable() { @Override public void run() {
return; if (Thread.currentThread() == channel.getIoThread()) { throw HttpClientMessages.MESSAGES.blockingIoFromIOThread();
@Override public XnioIoThread getIoThread() { return delegate.getIoThread(); }
@Override public XnioIoThread getIoThread() { return delegate.getIoThread(); }
public XnioIoThread getIoThread() { return delegate.getIoThread(); }
public XnioIoThread getWriteThread() { return channel.getIoThread(); }
public XnioIoThread getIoThread() { return delegate.getIoThread(); }
/** * execute a graceful shutdown once all data has been sent */ public void shutdown() { if (open == 0 || shutdown) { return; } shutdown = true; sink.getIoThread().execute(new Runnable() { @Override public void run() { synchronized (ServerSentEventConnection.this) { if (queue.isEmpty() && pooled == null) { exchange.endExchange(); } } } }); }
/** * execute a graceful shutdown once all data has been sent */ public void shutdown() { if (open == 0 || shutdown) { return; } shutdown = true; sink.getIoThread().execute(new Runnable() { @Override public void run() { synchronized (ServerSentEventConnection.this) { if (queue.isEmpty() && pooled == null) { exchange.endExchange(); } } } }); }
/** * Sends the 'retry' message to the client, instructing it how long to wait before attempting a reconnect. * * @param retry The retry time in milliseconds * @param callback The callback that is notified on success or failure */ public synchronized void sendRetry(long retry, EventCallback callback) { if (open == 0 || shutdown) { if (callback != null) { callback.failed(this, null, null, null, new ClosedChannelException()); } return; } queue.add(new SSEData(retry, callback)); sink.getIoThread().execute(new Runnable() { @Override public void run() { synchronized (ServerSentEventConnection.this) { if (pooled == null) { fillBuffer(); writeListener.handleEvent(sink); } } } }); }
/** * Sends an event to the remote client * * @param data The event data * @param event The event name * @param id The event ID * @param callback A callback that is notified on Success or failure */ public synchronized void send(String data, String event, String id, EventCallback callback) { if (open == 0 || shutdown) { if (callback != null) { callback.failed(this, data, event, id, new ClosedChannelException()); } return; } queue.add(new SSEData(event, data, id, callback)); sink.getIoThread().execute(new Runnable() { @Override public void run() { synchronized (ServerSentEventConnection.this) { if (pooled == null) { fillBuffer(); writeListener.handleEvent(sink); } } } }); }
/** * Sends an event to the remote client * * @param data The event data * @param event The event name * @param id The event ID * @param callback A callback that is notified on Success or failure */ public synchronized void send(String data, String event, String id, EventCallback callback) { if (open == 0 || shutdown) { if (callback != null) { callback.failed(this, data, event, id, new ClosedChannelException()); } return; } queue.add(new SSEData(event, data, id, callback)); sink.getIoThread().execute(new Runnable() { @Override public void run() { synchronized (ServerSentEventConnection.this) { if (pooled == null) { fillBuffer(); writeListener.handleEvent(sink); } } } }); }
@Override public void close() throws IOException { state |= FLAG_CLOSED; state &= ~FLAG_READY; if (listener == null) { channel.shutdownWrites(); state |= FLAG_DELEGATE_SHUTDOWN; Channels.flushBlocking(channel); } else { if (buffer == null) { channel.shutdownWrites(); state |= FLAG_DELEGATE_SHUTDOWN; if (!channel.flush()) { if (Thread.currentThread() == channel.getIoThread()) { channel.resumeWrites(); } else { ioExecutor.execute(new Runnable() { @Override public void run() { channel.resumeWrites(); } }); } } } } }