Package anbxj

Class Channel_ProtoServer

java.lang.Object
anbxj.Channel_Abstraction
anbxj.Channel_ProtoServer

public class Channel_ProtoServer extends Channel_Abstraction
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.

  • Constructor Details

    • Channel_ProtoServer

      public Channel_ProtoServer(Channel_Properties cp, Channel_MessageSerializer serializer)
      Constructs a new Channel_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), an SSLServerSocket is created, optionally with client authentication, and the TLS handshake is performed before the connection is handed to a Channel_Protobuf. For plain channels (SSL_NONE, SSL_PLAIN), a simple ServerSocket is used.

      Overrides:
      Open in class Channel_Abstraction
    • Send

      public void Send(Object obj)
      Sends an object through the current protobuf channel.
      Overrides:
      Send in class Channel_Abstraction
      Parameters:
      obj - the object to send
    • Receive

      public Object Receive()
      Receives an object from the current protobuf channel.
      Overrides:
      Receive in class Channel_Abstraction
      Returns:
      the received object
    • Close

      public void Close()
      Closes the underlying protobuf channel and the server socket.
      Overrides:
      Close in class Channel_Abstraction
    • setStep

      public void setStep(int step)
      Sets the current protocol step on the underlying protobuf channel.
      Overrides:
      setStep in class Channel_Abstraction
      Parameters:
      step - the step number
    • getChannelRole

      public Channel_Roles getChannelRole()
      Returns the role of this channel (always Channel_Roles.SERVER).
      Overrides:
      getChannelRole in class Channel_Abstraction
      Returns:
      Channel_Roles.SERVER
    • getSerializer

      public Channel_MessageSerializer getSerializer()