ESP OpenBCI - An EEG Signal Processing Library for OpenBCI Hardware

com.github.mrstampy.esp.multiconnectionsocket
Class AbstractSocketConnector<E extends java.lang.Enum<E>>

java.lang.Object
  extended by com.github.mrstampy.esp.multiconnectionsocket.AbstractSocketConnector<E>
Type Parameters:
E - the element type
Direct Known Subclasses:
OpenBCISocketConnector

public abstract class AbstractSocketConnector<E extends java.lang.Enum<E>>
extends java.lang.Object

This class connects to the AbstractMultiConnectionSocket and receives AbstractMultiConnectionEvent updates. Many instances of this class running in separate processes can connect to the single instance of AbstractMultiConnectionSocket, allowing separately running programs to deal with Neurosky output simultaneously.

Author:
burton

Field Summary
static int BROADCASTER_PORT
          The broadcaster port.
protected  org.apache.mina.transport.socket.nio.NioSocketConnector connector
          The connector.
static java.lang.String SOCKET_BROADCASTER_KEY
          Set the system property 'socket.broadcaster.port' on startup to change the broadcaster port from the default '12345' ie.
 
Constructor Summary
AbstractSocketConnector(java.lang.String socketBroadcasterHost)
          Instantiate with the name of the host that the AbstractMultiConnectionSocket is running on.
 
Method Summary
 void connect()
          Connects to the AbstractMultiConnectionSocket instance.
 void disconnect()
          Disconnects from the AbstractMultiConnectionSocket instance.
 boolean isConnected()
          Returns true if connected to a AbstractMultiConnectionSocket instance.
protected abstract  void processEvent(AbstractMultiConnectionEvent<E> message)
          Process event.
protected  boolean subscribe(MultiConnectionSubscriptionRequest<?> request)
          Subscribes to the specified event types, all registered listeners will receive updates for these event types.
abstract  boolean subscribeAll()
          Subscribes to all EventTypes, barring EventType#signalProcessed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SOCKET_BROADCASTER_KEY

public static final java.lang.String SOCKET_BROADCASTER_KEY
Set the system property 'socket.broadcaster.port' on startup to change the broadcaster port from the default '12345' ie. -Dsocket.broadcaster.port=54321

See Also:
Constant Field Values

BROADCASTER_PORT

public static int BROADCASTER_PORT
The broadcaster port.


connector

protected org.apache.mina.transport.socket.nio.NioSocketConnector connector
The connector.

Constructor Detail

AbstractSocketConnector

public AbstractSocketConnector(java.lang.String socketBroadcasterHost)
Instantiate with the name of the host that the AbstractMultiConnectionSocket is running on.

Parameters:
socketBroadcasterHost - the socket broadcaster host
Method Detail

isConnected

public boolean isConnected()
Returns true if connected to a AbstractMultiConnectionSocket instance.

Returns:
true if connected

connect

public void connect()
             throws MultiConnectionSocketException
Connects to the AbstractMultiConnectionSocket instance. The listeners will not be notified of events until #subscribe(EventType...) or subscribeAll() has been called.

Throws:
MultiConnectionSocketException - if unable to connect to a AbstractMultiConnectionSocket

disconnect

public void disconnect()
Disconnects from the AbstractMultiConnectionSocket instance.


subscribe

protected boolean subscribe(MultiConnectionSubscriptionRequest<?> request)
Subscribes to the specified event types, all registered listeners will receive updates for these event types. Returns true if successful.

Parameters:
request - the request
Returns:
true, if successful

subscribeAll

public abstract boolean subscribeAll()
Subscribes to all EventTypes, barring EventType#signalProcessed.

Returns:
true, if successful

processEvent

protected abstract void processEvent(AbstractMultiConnectionEvent<E> message)
Process event.

Parameters:
message - the message

brought to you by Mr. Stampy