ESP OpenBCI - An EEG Signal Processing Library for OpenBCI Hardware

com.github.mrstampy.esp.multiconnectionsocket
Class AbstractSubscriptionHandlerAdapter<E extends java.lang.Enum<E>,AMCS extends AbstractMultiConnectionSocket<?>,MCSR extends MultiConnectionSubscriptionRequest<E>>

java.lang.Object
  extended by org.apache.mina.core.service.IoHandlerAdapter
      extended by com.github.mrstampy.esp.multiconnectionsocket.AbstractSubscriptionHandlerAdapter<E,AMCS,MCSR>
Type Parameters:
E - enum representing the event type
AMCS - the AbstractMultiConnectionSocket implementation
MCSR - the MultiConnectionSubscriptionRequest
All Implemented Interfaces:
org.apache.mina.core.service.IoHandler
Direct Known Subclasses:
OpenBCISubscriptionHandlerAdapter

public abstract class AbstractSubscriptionHandlerAdapter<E extends java.lang.Enum<E>,AMCS extends AbstractMultiConnectionSocket<?>,MCSR extends MultiConnectionSubscriptionRequest<E>>
extends org.apache.mina.core.service.IoHandlerAdapter

Abstract IoHandler implementation to receive subscriptions and publish AbstractMultiConnectionEvents on a socket.

Author:
burton

Constructor Summary
protected AbstractSubscriptionHandlerAdapter(AMCS socket)
          Instantiates a new abstract subscription handler adapter.
 
Method Summary
protected  HostPort createHostPort(org.apache.mina.core.session.IoSession session)
          Creates the host port.
 AMCS getSocket()
          Gets the socket.
abstract  void messageReceived(org.apache.mina.core.session.IoSession session, java.lang.Object message)
          Implement to deal with subscription requests & any other message types the subclass must deal with.
 void sendMultiConnectionEvent(AbstractMultiConnectionEvent<E> event)
          Sends the specified AbstractMultiConnectionEvent to all interested subscribers.
 void sessionClosed(org.apache.mina.core.session.IoSession session)
           
protected  void setSocket(AMCS socket)
          Sets the socket.
protected  void subscribe(org.apache.mina.core.session.IoSession session, MCSR message)
          Subscribe.
 
Methods inherited from class org.apache.mina.core.service.IoHandlerAdapter
exceptionCaught, messageSent, sessionCreated, sessionIdle, sessionOpened
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractSubscriptionHandlerAdapter

protected AbstractSubscriptionHandlerAdapter(AMCS socket)
Instantiates a new abstract subscription handler adapter.

Parameters:
socket - the socket
Method Detail

messageReceived

public abstract void messageReceived(org.apache.mina.core.session.IoSession session,
                                     java.lang.Object message)
                              throws java.lang.Exception
Implement to deal with subscription requests & any other message types the subclass must deal with.

Specified by:
messageReceived in interface org.apache.mina.core.service.IoHandler
Overrides:
messageReceived in class org.apache.mina.core.service.IoHandlerAdapter
Parameters:
session - the session
message - the message
Throws:
java.lang.Exception - the exception
See Also:
subscribe(IoSession, MultiConnectionSubscriptionRequest)

sessionClosed

public void sessionClosed(org.apache.mina.core.session.IoSession session)
                   throws java.lang.Exception
Specified by:
sessionClosed in interface org.apache.mina.core.service.IoHandler
Overrides:
sessionClosed in class org.apache.mina.core.service.IoHandlerAdapter
Throws:
java.lang.Exception

sendMultiConnectionEvent

public void sendMultiConnectionEvent(AbstractMultiConnectionEvent<E> event)
Sends the specified AbstractMultiConnectionEvent to all interested subscribers.

Parameters:
event - the event
See Also:
AbstractMultiConnectionSocket, AbstractSocketConnector

subscribe

protected void subscribe(org.apache.mina.core.session.IoSession session,
                         MCSR message)
Subscribe.

Parameters:
session - the session
message - the message

getSocket

public AMCS getSocket()
Gets the socket.

Returns:
the socket

setSocket

protected void setSocket(AMCS socket)
Sets the socket.

Parameters:
socket - the new socket

createHostPort

protected HostPort createHostPort(org.apache.mina.core.session.IoSession session)
Creates the host port.

Parameters:
session - the session
Returns:
the host port

brought to you by Mr. Stampy