Class NettyStreamingService<T>
java.lang.Object
info.bitrich.xchangestream.service.ConnectableService
info.bitrich.xchangestream.service.netty.NettyStreamingService<T>
- Direct Known Subclasses:
GateioStreamingService
,JsonNettyStreamingService
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected class
protected class
-
Field Summary
Modifier and TypeFieldDescriptionprotected final Map<String,
NettyStreamingService<T>.Subscription> protected static final Duration
protected static final int
protected static final Duration
protected URI
Fields inherited from class info.bitrich.xchangestream.service.ConnectableService
BEFORE_CONNECTION_HANDLER
-
Constructor Summary
ConstructorDescriptionNettyStreamingService
(String apiUrl) NettyStreamingService
(String apiUrl, int maxFramePayloadLength) NettyStreamingService
(String apiUrl, int maxFramePayloadLength, Duration connectionTimeout, Duration retryDuration) NettyStreamingService
(String apiUrl, int maxFramePayloadLength, Duration connectionTimeout, Duration retryDuration, int idleTimeoutSeconds) -
Method Summary
Modifier and TypeMethodDescriptionio.reactivex.rxjava3.core.Completable
protected String
getChannel
(T message) protected abstract String
getChannelNameFromMessage
(T message) protected io.netty.handler.codec.http.DefaultHttpHeaders
abstract String
getSubscribeMessage
(String channelName, Object... args) getSubscriptionUniqueId
(String channelName, Object... args) abstract String
getUnsubscribeMessage
(String channelName, Object... args) protected io.netty.handler.codec.http.websocketx.extensions.WebSocketClientExtensionHandler
protected WebSocketClientHandler
getWebSocketClientHandler
(io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker handshaker, WebSocketClientHandler.WebSocketMessageHandler handler) protected void
handleChannelError
(String channel, Throwable t) protected void
handleChannelMessage
(String channel, T message) protected void
handleError
(T message, Throwable t) protected void
handleIdle
(io.netty.channel.ChannelHandlerContext ctx) protected void
handleMessage
(T message) boolean
abstract void
messageHandler
(String message) Handler that receives incoming messages.protected io.reactivex.rxjava3.core.Completable
void
void
sendMessage
(String message) void
setAcceptAllCertificates
(boolean acceptAllCertificates) void
setAutoReconnect
(boolean autoReconnect) void
setEnableLoggingHandler
(boolean enableLoggingHandler) void
setLoggingHandlerLevel
(io.netty.handler.logging.LogLevel loggingHandlerLevel) void
setSocksProxyHost
(String socksProxyHost) void
setSocksProxyPort
(Integer socksProxyPort) io.reactivex.rxjava3.core.Observable<T>
subscribeChannel
(String channelName, Object... args) io.reactivex.rxjava3.core.Observable<ConnectionStateModel.State>
io.reactivex.rxjava3.core.Observable<Object>
io.reactivex.rxjava3.core.Observable<Object>
io.reactivex.rxjava3.core.Observable<Object>
Observable which fires if the websocket is deemed idle, only fired ifidleTimeoutSeconds != 0
.io.reactivex.rxjava3.core.Observable<Throwable>
void
useCompressedMessages
(boolean compressedMessages) Methods inherited from class info.bitrich.xchangestream.service.ConnectableService
connect, setBeforeConnectionHandler
-
Field Details
-
DEFAULT_CONNECTION_TIMEOUT
-
DEFAULT_RETRY_DURATION
-
DEFAULT_IDLE_TIMEOUT
protected static final int DEFAULT_IDLE_TIMEOUT- See Also:
-
uri
-
channels
-
-
Constructor Details
-
NettyStreamingService
-
NettyStreamingService
-
NettyStreamingService
-
NettyStreamingService
-
-
Method Details
-
openConnection
protected io.reactivex.rxjava3.core.Completable openConnection()- Specified by:
openConnection
in classConnectableService
-
getCustomHeaders
protected io.netty.handler.codec.http.DefaultHttpHeaders getCustomHeaders() -
disconnect
public io.reactivex.rxjava3.core.Completable disconnect() -
getChannelNameFromMessage
- Throws:
IOException
-
getSubscribeMessage
- Throws:
IOException
-
getUnsubscribeMessage
- Throws:
IOException
-
getSubscriptionUniqueId
-
messageHandler
Handler that receives incoming messages.- Parameters:
message
- Content of the message from the server.
-
sendMessage
-
subscribeReconnectFailure
-
subscribeConnectionSuccess
-
subscribeDisconnect
-
subscribeConnectionState
-
subscribeChannel
-
resubscribeChannels
public void resubscribeChannels() -
getChannel
-
handleMessage
-
handleError
-
handleIdle
protected void handleIdle(io.netty.channel.ChannelHandlerContext ctx) -
subscribeIdle
Observable which fires if the websocket is deemed idle, only fired ifidleTimeoutSeconds != 0
. -
handleChannelMessage
-
handleChannelError
-
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
-
setSocksProxyPort
-
setAutoReconnect
public void setAutoReconnect(boolean autoReconnect)
-