org.resoa.stack.kernel.tcp
Class NetTCPGateway

java.lang.Object
  extended by org.resoa.stack.kernel.tcp.NetTCPGateway
All Implemented Interfaces:
TCPGateway

public class NetTCPGateway
extends java.lang.Object
implements TCPGateway

Convenient (Non NIO) implementation of TCPGateway


Nested Class Summary
 class NetTCPGateway.Acceptor
          Acceptor class
 
Constructor Summary
NetTCPGateway()
          Constructor
 
Method Summary
 int activeSessions()
          Returns the currently cached sessions
 void close(org.resoa.stack.config.HostStatus state, java.lang.String infoMsg)
          Disconnect from all connections
 void connectToRemote(Session session)
          Connect to an address
 void disconnect()
          Disconnect all sessions
 void disconnect(Session session)
          Disconnect from an address
 void init(Stack stack, int localHostIndex)
          Initializes the gateway
 void onAccept(Session session)
          Invoked after successful socket accept
 void onInitialized(Session session)
          Invoked after successful session connect handshake
 void pingSessions()
          Sends a PING ProtocolService message to all registered sessions
protected  void registerRemoteSession(Session session)
          Add an accepted session to cache
 void send(org.resoa.grid.Message msg)
          Sends a message to remote
 void setConnectionAccept(boolean accept)
          Allow or stops the connection accept.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NetTCPGateway

public NetTCPGateway()
Constructor

Method Detail

init

public void init(Stack stack,
                 int localHostIndex)
          throws java.io.IOException
Description copied from interface: TCPGateway
Initializes the gateway

Specified by:
init in interface TCPGateway
localHostIndex - set to -1, if no remote connections should be accepted
Throws:
java.io.IOException

registerRemoteSession

protected void registerRemoteSession(Session session)
Add an accepted session to cache

Parameters:
session -

activeSessions

public int activeSessions()
Description copied from interface: TCPGateway
Returns the currently cached sessions

Specified by:
activeSessions in interface TCPGateway
Returns:
the currently cached session count

setConnectionAccept

public void setConnectionAccept(boolean accept)
Description copied from interface: TCPGateway
Allow or stops the connection accept.

Specified by:
setConnectionAccept in interface TCPGateway

close

public void close(org.resoa.stack.config.HostStatus state,
                  java.lang.String infoMsg)
Description copied from interface: TCPGateway
Disconnect from all connections

Specified by:
close in interface TCPGateway
Parameters:
state - the new state
infoMsg - a info message

disconnect

public void disconnect()
Description copied from interface: TCPGateway
Disconnect all sessions

Specified by:
disconnect in interface TCPGateway

disconnect

public void disconnect(Session session)
Description copied from interface: TCPGateway
Disconnect from an address

Specified by:
disconnect in interface TCPGateway

connectToRemote

public void connectToRemote(Session session)
                     throws java.io.IOException
Description copied from interface: TCPGateway
Connect to an address

Specified by:
connectToRemote in interface TCPGateway
Throws:
java.io.IOException

onAccept

public void onAccept(Session session)
Description copied from interface: TCPGateway
Invoked after successful socket accept

Specified by:
onAccept in interface TCPGateway

onInitialized

public void onInitialized(Session session)
Description copied from interface: TCPGateway
Invoked after successful session connect handshake

Specified by:
onInitialized in interface TCPGateway

send

public void send(org.resoa.grid.Message msg)
          throws org.resoa.exception.ProtocolException,
                 java.io.IOException
Description copied from interface: TCPGateway
Sends a message to remote

Specified by:
send in interface TCPGateway
Parameters:
msg - the message to send
Throws:
org.resoa.exception.ProtocolException
java.io.IOException

pingSessions

public void pingSessions()
Description copied from interface: TCPGateway
Sends a PING ProtocolService message to all registered sessions

Specified by:
pingSessions in interface TCPGateway


Copyright © 2007 www.resoa.org. All Rights Reserved.