Package org.yamcs.client.base
Class WebSocketClient
- java.lang.Object
-
- org.yamcs.client.base.WebSocketClient
-
public class WebSocketClient extends Object
Netty-implementation of a Yamcs web socket client.
-
-
Constructor Summary
Constructors Constructor Description WebSocketClient(String host, int port, boolean tls, String context, WebSocketClientCallback callback)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends com.google.protobuf.Message>
Observer<T>call(String type, DataObserver<? extends com.google.protobuf.Message> observer)Initiates a new call.voidcancelCall(int callId)io.netty.channel.ChannelFutureconnect(String accessToken)voiddisconnect()voidenableTcpKeepAlive(boolean enableTcpKeepAlive)Enable/disable the TCP Keep-Alive on websocket sockets.intgetMaxFramePayloadLength()voidhandleMessage(ServerMessage message)booleanisConnected()booleanisInsecureTls()voidsetCaCertFile(String caCertFile)In case of https connections, this file contains the CA certificates that are used to verify server certificatevoidsetConnectionTimeoutMs(int timeoutMs)voidsetInsecureTls(boolean insecureTls)if true and https connections are used, do not verify server certificatevoidsetMaxFramePayloadLength(int maxFramePayloadLength)voidsetMessageLogging(Level level)Enables logging of all inbound and outbound messages on the request logging level.voidsetUserAgent(String userAgent)io.netty.util.concurrent.Future<?>shutdown()
-
-
-
Constructor Detail
-
WebSocketClient
public WebSocketClient(String host, int port, boolean tls, String context, WebSocketClientCallback callback)
-
-
Method Detail
-
setUserAgent
public void setUserAgent(String userAgent)
-
setConnectionTimeoutMs
public void setConnectionTimeoutMs(int timeoutMs)
-
setMessageLogging
public void setMessageLogging(Level level)
Enables logging of all inbound and outbound messages on the request logging level.By default set to
Level.FINEST
-
connect
public io.netty.channel.ChannelFuture connect(String accessToken) throws SSLException, GeneralSecurityException
- Throws:
SSLExceptionGeneralSecurityException
-
call
public <T extends com.google.protobuf.Message> Observer<T> call(String type, DataObserver<? extends com.google.protobuf.Message> observer)
Initiates a new call. This does not yet communicate to Yamcs. Use the returned observer to send one or more messages.
-
cancelCall
public void cancelCall(int callId) throws IOException- Throws:
IOException
-
disconnect
public void disconnect()
-
enableTcpKeepAlive
public void enableTcpKeepAlive(boolean enableTcpKeepAlive)
Enable/disable the TCP Keep-Alive on websocket sockets. By default it is disabled. It has to be enabled before the connection is established.- Parameters:
enableTcpKeepAlive- if true the TCP SO_KEEPALIVE option is set
-
shutdown
public io.netty.util.concurrent.Future<?> shutdown()
- Returns:
- the Future which is notified when the executor has been terminated.
-
isConnected
public boolean isConnected()
-
setCaCertFile
public void setCaCertFile(String caCertFile) throws IOException, GeneralSecurityException
In case of https connections, this file contains the CA certificates that are used to verify server certificate- Parameters:
caCertFile-- Throws:
IOExceptionGeneralSecurityException
-
isInsecureTls
public boolean isInsecureTls()
-
setInsecureTls
public void setInsecureTls(boolean insecureTls)
if true and https connections are used, do not verify server certificate- Parameters:
insecureTls-
-
getMaxFramePayloadLength
public int getMaxFramePayloadLength()
-
setMaxFramePayloadLength
public void setMaxFramePayloadLength(int maxFramePayloadLength)
-
handleMessage
public void handleMessage(ServerMessage message) throws com.google.protobuf.InvalidProtocolBufferException
- Throws:
com.google.protobuf.InvalidProtocolBufferException
-
-