/** * Get the interval of periodical * <a href="https://tools.ietf.org/html/rfc6455#section-5.5.3">pong</a> * frames. * * @return * The interval in milliseconds. * * @since 1.2 */ public long getPongInterval() { return mPongSender.getInterval(); }
/** * Get the generator of payload of pong frames that are sent automatically. * * @return * The generator of payload pong frames that are sent automatically. * * @since 1.20 */ public PayloadGenerator getPongPayloadGenerator() { return mPongSender.getPayloadGenerator(); }
/** * Get the name of the {@code Timer} that sends pong frames periodically. * * @return * The {@code Timer}'s name. * * @since 2.5 */ public String getPongSenderName() { return mPongSender.getTimerName(); }
WebSocket(WebSocketFactory factory, boolean secure, String userInfo, String host, String path, SocketConnector connector) { mWebSocketFactory = factory; mSocketConnector = connector; mStateManager = new StateManager(); mHandshakeBuilder = new HandshakeBuilder(secure, userInfo, host, path); mListenerManager = new ListenerManager(this); mPingSender = new PingSender(this, new CounterPayloadGenerator()); mPongSender = new PongSender(this, new CounterPayloadGenerator()); }
/** * Called when both the reading thread and the writing thread have started. * This method is called in the context of either the reading thread or * the writing thread. */ private void onThreadsStarted() { // Start sending ping frames periodically. // If the interval is zero, this call does nothing. mPingSender.start(); // Likewise, start the pong sender. mPongSender.start(); }
/** * Set the generator of payload of pong frames that are sent automatically. * * @param generator * The generator of payload ppng frames that are sent automatically. * * @since 1.20 */ public WebSocket setPongPayloadGenerator(PayloadGenerator generator) { mPongSender.setPayloadGenerator(generator); return this; }
/** * Set the name of the {@code Timer} that sends pong frames periodically. * * @param name * A name for the {@code Timer}. * * @return * {@code this} object. * * @since 2.5 */ public WebSocket setPongSenderName(String name) { mPongSender.setTimerName(name); return this; }
void finish() { // Stop the ping sender and the pong sender. mPingSender.stop(); mPongSender.stop(); try { // Close the raw socket. mSocketConnector.getSocket().close(); } catch (Throwable t) { // Ignore any error raised by close(). } synchronized (mStateManager) { // Change the state to CLOSED. mStateManager.setState(CLOSED); } // Notify the listeners of the state change. mListenerManager.callOnStateChanged(CLOSED); // Notify the listeners that the WebSocket was disconnected. mListenerManager.callOnDisconnected( mServerCloseFrame, mClientCloseFrame, mStateManager.getClosedByServer()); }
mPongSender.setInterval(interval);
WebSocket(WebSocketFactory factory, boolean secure, String userInfo, String host, String path, SocketConnector connector) { mWebSocketFactory = factory; mSocketConnector = connector; mStateManager = new StateManager(); mHandshakeBuilder = new HandshakeBuilder(secure, userInfo, host, path); mListenerManager = new ListenerManager(this); mPingSender = new PingSender(this, new CounterPayloadGenerator()); mPongSender = new PongSender(this, new CounterPayloadGenerator()); }
/** * Called when both the reading thread and the writing thread have started. * This method is called in the context of either the reading thread or * the writing thread. */ private void onThreadsStarted() { // Start sending ping frames periodically. // If the interval is zero, this call does nothing. mPingSender.start(); // Likewise, start the pong sender. mPongSender.start(); }
/** * Set the generator of payload of pong frames that are sent automatically. * * @param generator * The generator of payload ppng frames that are sent automatically. * * @since 1.20 */ public WebSocket setPongPayloadGenerator(PayloadGenerator generator) { mPongSender.setPayloadGenerator(generator); return this; }
/** * Set the name of the {@code Timer} that sends pong frames periodically. * * @param name * A name for the {@code Timer}. * * @return * {@code this} object. * * @since 2.5 */ public WebSocket setPongSenderName(String name) { mPongSender.setTimerName(name); return this; }
void finish() { // Stop the ping sender and the pong sender. mPingSender.stop(); mPongSender.stop(); try { // Close the raw socket. mSocketConnector.getSocket().close(); } catch (Throwable t) { // Ignore any error raised by close(). } synchronized (mStateManager) { // Change the state to CLOSED. mStateManager.setState(CLOSED); } // Notify the listeners of the state change. mListenerManager.callOnStateChanged(CLOSED); // Notify the listeners that the WebSocket was disconnected. mListenerManager.callOnDisconnected( mServerCloseFrame, mClientCloseFrame, mStateManager.getClosedByServer()); }
mPongSender.setInterval(interval);
/** * Get the generator of payload of pong frames that are sent automatically. * * @return * The generator of payload pong frames that are sent automatically. * * @since 1.20 */ public PayloadGenerator getPongPayloadGenerator() { return mPongSender.getPayloadGenerator(); }
/** * Get the name of the {@code Timer} that sends pong frames periodically. * * @return * The {@code Timer}'s name. * * @since 2.5 */ public String getPongSenderName() { return mPongSender.getTimerName(); }
/** * Get the interval of periodical * <a href="https://tools.ietf.org/html/rfc6455#section-5.5.3">pong</a> * frames. * * @return * The interval in milliseconds. * * @since 1.2 */ public long getPongInterval() { return mPongSender.getInterval(); }