Package anbxj
Class Channel_ProtoServer
java.lang.Object
anbxj.Channel_Abstraction
anbxj.Channel_ProtoServer
A single-connection server that uses a
Channel_MessageSerializer
and a Channel_Protobuf wrapper for length-delimited communication.
When the channel properties indicate SSL/TLS is required, this server
will create an SSLServerSocket, perform the TLS handshake, and
only then hand the socket to Channel_Protobuf. For plain
connections, a standard ServerSocket is used.
-
Field Summary
Fields inherited from class anbxj.Channel_Abstraction
cp -
Constructor Summary
ConstructorsConstructorDescriptionChannel_ProtoServer(Channel_Properties cp, Channel_MessageSerializer serializer) Constructs a newChannel_ProtoServer. -
Method Summary
Modifier and TypeMethodDescriptionvoidClose()Closes the underlying protobuf channel and the server socket.Returns the role of this channel (alwaysChannel_Roles.SERVER).voidOpen()Opens the server socket and waits for a single client connection.Receive()Receives an object from the current protobuf channel.voidSends an object through the current protobuf channel.voidsetStep(int step) Sets the current protocol step on the underlying protobuf channel.Methods inherited from class anbxj.Channel_Abstraction
checkPort, getChannelSettings, OpenStreams, Receive, safeReadObject
-
Constructor Details
-
Channel_ProtoServer
Constructs a newChannel_ProtoServer.- Parameters:
cp- the channel properties (host, port, security type, etc.)serializer- the message serializer that will be used for every accepted connection
-
-
Method Details
-
Open
public void Open()Opens the server socket and waits for a single client connection.If the channel type requires SSL/TLS (e.g.,
SSL_AUTH,SSL_SECRET,SSL_SECURE), anSSLServerSocketis created, optionally with client authentication, and the TLS handshake is performed before the connection is handed to aChannel_Protobuf. For plain channels (SSL_NONE,SSL_PLAIN), a simpleServerSocketis used.- Overrides:
Openin classChannel_Abstraction
-
Send
Sends an object through the current protobuf channel.- Overrides:
Sendin classChannel_Abstraction- Parameters:
obj- the object to send
-
Receive
Receives an object from the current protobuf channel.- Overrides:
Receivein classChannel_Abstraction- Returns:
- the received object
-
Close
public void Close()Closes the underlying protobuf channel and the server socket.- Overrides:
Closein classChannel_Abstraction
-
setStep
public void setStep(int step) Sets the current protocol step on the underlying protobuf channel.- Overrides:
setStepin classChannel_Abstraction- Parameters:
step- the step number
-
getChannelRole
Returns the role of this channel (alwaysChannel_Roles.SERVER).- Overrides:
getChannelRolein classChannel_Abstraction- Returns:
Channel_Roles.SERVER
-
getSerializer
-