org.vigia.server.communications
Class ControlCommunicator

java.lang.Object
  extended by org.vigia.server.communications.ControlCommunicator

public class ControlCommunicator
extends java.lang.Object

Implements the server control communication.

Author:
jrios

Nested Class Summary
protected  class ControlCommunicator.ControlCommunicatorReader
          This class accepts clients, reads from the socket and sends the commands to the listeners.
 
Field Summary
protected  java.net.Socket client
          The socket to communicate with the clients.
protected  java.util.Set<CommandListener> commandListeners
          The registered listeners.
protected  java.net.ServerSocket server
          The socket to wait clients.
 
Constructor Summary
ControlCommunicator(int controlPort)
          Creates a new ControlCommunicator.
 
Method Summary
 void addCommandListener(CommandListener commandListener)
          Adds a listener to obtain control messages from the remote camera.
 void sendLog(ELog log, java.lang.String message)
          Sends a log message to the client.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

server

protected java.net.ServerSocket server
The socket to wait clients.


client

protected java.net.Socket client
The socket to communicate with the clients.


commandListeners

protected java.util.Set<CommandListener> commandListeners
The registered listeners.

Constructor Detail

ControlCommunicator

public ControlCommunicator(int controlPort)
                    throws java.io.IOException
Creates a new ControlCommunicator.

Parameters:
controlPort - The control port.
Throws:
java.io.IOException - Error creating the socket.
Method Detail

addCommandListener

public void addCommandListener(CommandListener commandListener)
Adds a listener to obtain control messages from the remote camera.

Parameters:
commandListener - an implementation of the control listener.

sendLog

public void sendLog(ELog log,
                    java.lang.String message)
             throws NotConnectedException,
                    java.io.IOException
Sends a log message to the client.

Parameters:
log - the kind of log event.
message - the log message.
Throws:
NotConnectedException - There isn't any client.
java.io.IOException - Error writing to the socket.