Package marauroa.server.net
Interface INetworkServerManager
- All Known Implementing Classes:
NetworkServerManager
public interface INetworkServerManager
A Network Server Manager is an active object ( a thread ) that send and
receive messages from clients. There is not transport or technology imposed.
The Write method is immediate, just call it with the message to send, making sure that you have correctly filled SourceAddress and ClientID. The message will then be sent to the Client. The Read method is blocking, when you call the Read method it either returns a message from the queue or if the queue is empty the thread blocks (sleeps) until one arrives.
The Network Manager is our router that sends and receives messages to and from the network. The manager exposes the interfaces that allow:
- Reading a message from the network
- Sending a message to the network
- Finalizing the manager
The Write method is immediate, just call it with the message to send, making sure that you have correctly filled SourceAddress and ClientID. The message will then be sent to the Client. The Read method is blocking, when you call the Read method it either returns a message from the queue or if the queue is empty the thread blocks (sleeps) until one arrives.
- Author:
- miguel
-
Method Summary
Modifier and TypeMethodDescriptionvoid
disconnectClient(Channel channel)
This method disconnect a client or silently fails if client doesn't exists.void
finish()
This method notify the active object to finish it executiongetChannel(Object internalChannel)
gets the channel associated with an internalChannelThis method blocks until a message is availableThis method provides the connection validator object.void
Register a listener that will be called when a disconnected event happens.void
sendMessage(Message msg)
This method add a message to be delivered to the client the message is pointed to.void
start()
This method inits the active object
-
Method Details
-
registerDisconnectedListener
Register a listener that will be called when a disconnected event happens. It is up to the implementer if this call add or replace the actual listener.- Parameters:
listener
- a listener of disconnection events.
-
getValidator
ConnectionValidator getValidator()This method provides the connection validator object. You can use it to ban connection IP.- Returns:
- validator.
-
getMessage
Message getMessage()This method blocks until a message is available- Returns:
- a Message
-
sendMessage
This method add a message to be delivered to the client the message is pointed to.- Parameters:
msg
- the message to be delivered.
-
disconnectClient
This method disconnect a client or silently fails if client doesn't exists.- Parameters:
channel
-
-
start
void start()This method inits the active object -
finish
void finish()This method notify the active object to finish it execution -
getChannel
gets the channel associated with an internalChannel- Parameters:
internalChannel
- internel channel- Returns:
- Channel
-