Class NettyStreamingService<T>

java.lang.Object
info.bitrich.xchangestream.service.ConnectableService
info.bitrich.xchangestream.service.netty.NettyStreamingService<T>
Direct Known Subclasses:
JsonNettyStreamingService

public abstract class NettyStreamingService<T>
extends ConnectableService
  • Field Details

  • Constructor Details

    • NettyStreamingService

      public NettyStreamingService​(String apiUrl)
    • NettyStreamingService

      public NettyStreamingService​(String apiUrl, int maxFramePayloadLength)
    • NettyStreamingService

      public NettyStreamingService​(String apiUrl, int maxFramePayloadLength, Duration connectionTimeout, Duration retryDuration)
    • NettyStreamingService

      public NettyStreamingService​(String apiUrl, int maxFramePayloadLength, Duration connectionTimeout, Duration retryDuration, int idleTimeoutSeconds)
  • Method Details

    • openConnection

      protected io.reactivex.Completable openConnection()
      Specified by:
      openConnection in class ConnectableService
    • getCustomHeaders

      protected io.netty.handler.codec.http.DefaultHttpHeaders getCustomHeaders()
    • disconnect

      public io.reactivex.Completable disconnect()
    • getChannelNameFromMessage

      protected abstract String getChannelNameFromMessage​(T message) throws IOException
      Throws:
      IOException
    • getSubscribeMessage

      public abstract String getSubscribeMessage​(String channelName, Object... args) throws IOException
      Throws:
      IOException
    • getUnsubscribeMessage

      public abstract String getUnsubscribeMessage​(String channelName, Object... args) throws IOException
      Throws:
      IOException
    • getSubscriptionUniqueId

      public String getSubscriptionUniqueId​(String channelName, Object... args)
    • messageHandler

      public abstract void messageHandler​(String message)
      Handler that receives incoming messages.
      Parameters:
      message - Content of the message from the server.
    • sendMessage

      public void sendMessage​(String message)
    • subscribeReconnectFailure

      public io.reactivex.Observable<Throwable> subscribeReconnectFailure()
    • subscribeConnectionSuccess

      public io.reactivex.Observable<Object> subscribeConnectionSuccess()
    • subscribeDisconnect

      public io.reactivex.Observable<Object> subscribeDisconnect()
    • subscribeConnectionState

      public io.reactivex.Observable<ConnectionStateModel.State> subscribeConnectionState()
    • subscribeChannel

      public io.reactivex.Observable<T> subscribeChannel​(String channelName, Object... args)
    • resubscribeChannels

      public void resubscribeChannels()
    • getChannel

      protected String getChannel​(T message)
    • handleMessage

      protected void handleMessage​(T message)
    • handleError

      protected void handleError​(T message, Throwable t)
    • handleIdle

      protected void handleIdle​(io.netty.channel.ChannelHandlerContext ctx)
    • subscribeIdle

      public io.reactivex.Observable<Object> subscribeIdle()
      Observable which fires if the websocket is deemed idle, only fired if idleTimeoutSeconds != 0.
    • handleChannelMessage

      protected void handleChannelMessage​(String channel, T message)
    • handleChannelError

      protected void handleChannelError​(String channel, Throwable t)
    • getWebSocketClientExtensionHandler

      protected io.netty.handler.codec.http.websocketx.extensions.WebSocketClientExtensionHandler getWebSocketClientExtensionHandler()
    • getWebSocketClientHandler

      protected WebSocketClientHandler getWebSocketClientHandler​(io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker handshaker, WebSocketClientHandler.WebSocketMessageHandler handler)
    • isSocketOpen

      public boolean isSocketOpen()
    • useCompressedMessages

      public void useCompressedMessages​(boolean compressedMessages)
    • setAcceptAllCertificates

      public void setAcceptAllCertificates​(boolean acceptAllCertificates)
    • setEnableLoggingHandler

      public void setEnableLoggingHandler​(boolean enableLoggingHandler)
    • setLoggingHandlerLevel

      public void setLoggingHandlerLevel​(io.netty.handler.logging.LogLevel loggingHandlerLevel)
    • setSocksProxyHost

      public void setSocksProxyHost​(String socksProxyHost)
    • setSocksProxyPort

      public void setSocksProxyPort​(Integer socksProxyPort)
    • setAutoReconnect

      public void setAutoReconnect​(boolean autoReconnect)