|
ESP OpenBCI - An EEG Signal Processing Library for OpenBCI Hardware | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.github.mrstampy.esp.multiconnectionsocket.AbstractMultiConnectionSocket<MESSAGE>
MESSAGE - the generic typepublic abstract class AbstractMultiConnectionSocket<MESSAGE>
Abstract implementation of a MultiConnectionSocket. This superclass
uses Disruptor to pull EEG device messages off a socket and pass them to an
Executor for processing.
Subclasses type the format of the raw data messages. Should multiple types
ie. double and byte arrays be received from the device then a serializable
wrapper can be created to contain the data.
| Constructor Summary | |
|---|---|
protected |
AbstractMultiConnectionSocket(boolean broadcasting)
Instantiates a new abstract multi connection socket. |
| Method Summary | |
|---|---|
void |
addConnectionEventListener(ConnectionEventListener listener)
Adds the connection event listener. |
void |
bindBroadcaster()
Binds the broadcaster to the local host and the broadcaster port in AbstractSocketConnector. |
boolean |
canBroadcast()
Returns true if this instance has been configured for broadcasting. |
void |
clearConnectionEventListeners()
Clear connection event listeners. |
protected abstract org.apache.mina.core.service.IoHandler |
getHandlerAdapter()
Gets the handler adapter. |
int |
getNumChannels()
Returns the number of channels. |
protected void |
initBroadCaster()
Initialization of the broadcaster, to send AbstractMultiConnectionEvents to remote processes which have
registered for subscriptions. |
boolean |
isBound()
Returns true if the broadcaster is bound. |
protected void |
notifyConnectionEventListeners(ConnectionEvent.State state)
Notify connection event listeners. |
protected abstract void |
parseMessage(MESSAGE message)
Invoked via Disruptor's onEvent processing, implement to notify event listeners and any multi connection subscribers. |
protected void |
publishMessage(MESSAGE message)
EEG device messages are passed to this method which uses Disruptor to pass the message asynchronously for processing by subclasses. |
void |
removeConnectionEventListener(ConnectionEventListener listener)
Removes the connection event listener. |
void |
setNumChannels(int numChannels)
Sets the num channels. |
void |
start()
Connects to the socket. |
protected abstract void |
startImpl()
Implement to create a connection to the EEG device. |
void |
stop()
Closes the connection to the AbstractMultiConnectionSocket socket. |
protected abstract void |
stopImpl()
Implement to close the connection to the EEG device. |
void |
unbindBroadcaster()
Unbinds the broadcaster. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.github.mrstampy.esp.multiconnectionsocket.MultiConnectionSocket |
|---|
getChannel, getChannels, isConnected |
| Constructor Detail |
|---|
protected AbstractMultiConnectionSocket(boolean broadcasting)
throws java.io.IOException
broadcasting - the broadcasting
java.io.IOException - Signals that an I/O exception has occurred.| Method Detail |
|---|
public final void start()
throws MultiConnectionSocketException
MultiConnectionSocket
start in interface MultiConnectionSocketMultiConnectionSocketException - if already connected or an unexpected error occurs
protected abstract void startImpl()
throws MultiConnectionSocketException
AbstractMultiConnectionSocket#publishMessage(String) method.
MultiConnectionSocketException - the multi connection socket exceptionAbstractMultiConnectionSocket#publishMessage(String)public void stop()
MultiConnectionSocketAbstractMultiConnectionSocket socket.
stop in interface MultiConnectionSocketprotected abstract void stopImpl()
public void addConnectionEventListener(ConnectionEventListener listener)
MultiConnectionSocket
addConnectionEventListener in interface MultiConnectionSocketlistener - the listenerpublic void removeConnectionEventListener(ConnectionEventListener listener)
MultiConnectionSocket
removeConnectionEventListener in interface MultiConnectionSocketlistener - the listenerpublic void clearConnectionEventListeners()
MultiConnectionSocket
clearConnectionEventListeners in interface MultiConnectionSocket
public void bindBroadcaster()
throws java.io.IOException
MultiConnectionSocketAbstractSocketConnector.
bindBroadcaster in interface MultiConnectionSocketjava.io.IOException - Signals that an I/O exception has occurred.AbstractSocketConnectorpublic void unbindBroadcaster()
MultiConnectionSocket
unbindBroadcaster in interface MultiConnectionSocketAbstractSocketConnectorpublic boolean canBroadcast()
MultiConnectionSocket
canBroadcast in interface MultiConnectionSocketpublic boolean isBound()
MultiConnectionSocket
isBound in interface MultiConnectionSocketAbstractSocketConnectorprotected void notifyConnectionEventListeners(ConnectionEvent.State state)
state - the state
protected void initBroadCaster()
throws java.io.IOException
AbstractMultiConnectionEvents to remote processes which have
registered for subscriptions. Invoke during object creation.
java.io.IOException - Signals that an I/O exception has occurred.protected abstract org.apache.mina.core.service.IoHandler getHandlerAdapter()
protected void publishMessage(MESSAGE message)
message - the messageAbstractMultiConnectionSocket#parseMessage(String)protected abstract void parseMessage(MESSAGE message)
message - the messagepublic int getNumChannels()
MultiConnectionSocket
getNumChannels in interface MultiConnectionSocketpublic void setNumChannels(int numChannels)
numChannels - the new num channels
|
brought to you by Mr. Stampy | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||