Package sk.ipesoft.d2000.d2japi
Interface ServerSocketEventsListener
-
public interface ServerSocketEventsListener
Listener for incoming connections when JAPI is in reverse connect mode.For each incoming connection the methods are called in the following order:
createEventsListener(InetAddress, int, ListeningHandle)
to accept or reject incoming connection by application level logic.- Internals of JAPI - triple handshake, to verify that the connecting client is D2Connector.exe with proper version.
- If triple handshake is successfully passed then
onConnectionEstabilished(D2Connector, InetAddress, int, ListeningHandle)
is called with new instance ofD2Connector
ready to use. OtherwiseonConnectionFailed(ConnectorException, InetAddress, int, ListeningHandle)
is called.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description D2ConnectorEventsListener
createEventsListener(java.net.InetAddress address, int port, ListeningHandle handle)
Called to accept or reject new incoming connection and possibly provide an instance ofD2ConnectorEventsListener
for constructor of newD2Connector
instance.void
onConnectionEstabilished(D2Connector connector, java.net.InetAddress address, int port, ListeningHandle handle)
Called when triple handshake connection verified validity of connecting client and new instance ofD2Connector
has been created.void
onConnectionFailed(ConnectorException ex, java.net.InetAddress address, int port, ListeningHandle handle)
Called when connecting client does not pass through initial triple handshake procedure.
-
-
-
Method Detail
-
createEventsListener
D2ConnectorEventsListener createEventsListener(java.net.InetAddress address, int port, ListeningHandle handle) throws ConnectionRejectedException
Called to accept or reject new incoming connection and possibly provide an instance ofD2ConnectorEventsListener
for constructor of newD2Connector
instance. Method is called prior triple handshake procedure.Incoming connection is accepted by returning either instance of connector listener or
null
if no listener is required.Incoming connection is validly rejected by throwing
ConnectionRejectedException
. Connection would be rejected also if call throws anyRuntimeException
although it is considered an error that is logged accordingly.- Parameters:
address
- address of connecting remote hostport
- port of connecting remote hosthandle
- handle to listening socket- Returns:
- instance of listener or
null
to be used as a parameter for construction of a new instance ofD2Connector
when incoming connection is to be accepted by application layer - Throws:
ConnectionRejectedException
- when incoming connection is to be rejected
-
onConnectionEstabilished
void onConnectionEstabilished(D2Connector connector, java.net.InetAddress address, int port, ListeningHandle handle)
Called when triple handshake connection verified validity of connecting client and new instance ofD2Connector
has been created. Instance is ready for use.- Parameters:
connector
- new instance of connector ready for useaddress
- remote address of D2Connector.exeport
- port of connected remote D2Connector.exehandle
- handle to listening socket
-
onConnectionFailed
void onConnectionFailed(ConnectorException ex, java.net.InetAddress address, int port, ListeningHandle handle)
Called when connecting client does not pass through initial triple handshake procedure. It happens when the client does not use JAPI communication protocol or when different version of D2Connector.exe attempts to connect.- Parameters:
ex
- actual exception that was thrown during connection establishmentaddress
- address of remote clientport
- port of remote clienthandle
- handle to listening socket
-
-