class MasterSession extends SAMv3StreamSession implements SAMDatagramReceiver, SAMRawReceiver, SAMMessageSess, I2PSessionMuxedListener
SAMStreamSession.DisconnectListener, SAMStreamSession.SAMStreamSessionServer, SAMStreamSession.SAMStreamSessionSocketReader, SAMStreamSession.SAMv1StreamSessionSocketReader, SAMStreamSession.StreamSender
_isOwnSession, _log, canCreate, DEFAULT_FORCE_FLUSH, forceFlush, PROP_FORCE_FLUSH, recv, server, SOCKET_HANDLER_BUF_SIZE, socketMgr
Constructor and Description |
---|
MasterSession(String nick,
SAMv3DatagramServer dgServer,
SAMv3Handler handler,
Properties props)
Build a Session according to information
registered with the given nickname.
|
Modifier and Type | Method and Description |
---|---|
void |
accept(SAMv3Handler handler,
boolean verbose)
Accept a single incoming STREAM on the socket stolen from the handler.
|
String |
add(String nick,
String style,
Properties props)
Add a session
|
void |
close()
Close the master session
Overridden to stop the acceptor.
|
void |
connect(SAMv3Handler handler,
String dest,
Properties props)
Connect the SAM STREAM session to the specified Destination
for a single connection, using the socket stolen from the handler.
|
void |
disconnected(I2PSession session)
Notify the client that the session has been terminated.
|
void |
errorOccurred(I2PSession session,
String message,
Throwable error)
Notify the client that some error occurred.
|
int |
getListenPort() |
int |
getListenProtocol() |
void |
messageAvailable(I2PSession session,
int msgId,
long size)
Will be called only if you register via
setSessionListener() or addSessionListener().
|
void |
messageAvailable(I2PSession session,
int msgId,
long size,
int proto,
int fromPort,
int toPort)
Instruct the client that the given session has received a message
Will be called only if you register via addMuxedSessionListener().
|
void |
receiveDatagramBytes(Destination sender,
byte[] data,
int proto,
int fromPort,
int toPort)
Send a byte array to a SAM client.
|
void |
receiveRawBytes(byte[] data,
int proto,
int fromPort,
int toPort)
Send a byte array to a SAM client, without informations
regarding the sender.
|
String |
remove(String nick,
Properties props)
Remove a session
|
void |
reportAbuse(I2PSession session,
int severity)
Instruct the client that the session specified seems to be under attack
and that the client may wish to move its destination to another router.
|
void |
start()
Overridden to start the acceptor.
|
void |
startForwardingIncoming(Properties props,
boolean sendPorts)
Forward sockets from I2P to the host/port provided.
|
void |
stopDatagramReceiving()
Does nothing.
|
void |
stopForwardingIncoming()
does nothing
|
void |
stopRawReceiving()
Does nothing.
|
getDB, getNick, getSocketServer, queueSocket
checkSocketHandlerId, closeConnection, connect, createSocketHandler, getDestination, getSocketReader, newSAMStreamSessionSocketReader, newStreamSender, removeSocketHandler, sendBytes, sendBytes, sendBytes, setReceiveLimit
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getDestination, sendBytes, sendBytes
public MasterSession(String nick, SAMv3DatagramServer dgServer, SAMv3Handler handler, Properties props) throws IOException, DataFormatException, SAMException
nick
- nickname of the sessionIOException
DataFormatException
SAMException
public void start()
start
in interface SAMMessageSess
start
in class SAMStreamSession
public String add(String nick, String style, Properties props)
public String remove(String nick, Properties props)
public void receiveDatagramBytes(Destination sender, byte[] data, int proto, int fromPort, int toPort) throws IOException
SAMDatagramReceiver
receiveDatagramBytes
in interface SAMDatagramReceiver
sender
- Destinationdata
- Byte array to be receivedproto
- I2CP protocolfromPort
- I2CP from porttoPort
- I2CP to portIOException
- alwayspublic void stopDatagramReceiving()
stopDatagramReceiving
in interface SAMDatagramReceiver
public void receiveRawBytes(byte[] data, int proto, int fromPort, int toPort) throws IOException
SAMRawReceiver
receiveRawBytes
in interface SAMRawReceiver
data
- Byte array to be receivedproto
- I2CP protocolfromPort
- I2CP from porttoPort
- I2CP to portIOException
- alwayspublic void stopRawReceiving()
stopRawReceiving
in interface SAMRawReceiver
public void connect(SAMv3Handler handler, String dest, Properties props) throws I2PException
SAMv3StreamSession
connect
in class SAMv3StreamSession
handler
- The handler that communicates with the requesting clientdest
- Base64-encoded Destination to connect toprops
- Options to be used for connectionI2PException
- alwayspublic void accept(SAMv3Handler handler, boolean verbose) throws SAMException
SAMv3StreamSession
accept
in class SAMv3StreamSession
handler
- The handler that communicates with the requesting clientverbose
- If true, SAM will send the Base64-encoded peer Destination of an
incoming socket as the first line of data sent to its client
on the handler socketSAMException
- alwayspublic void startForwardingIncoming(Properties props, boolean sendPorts) throws SAMException
SAMv3StreamSession
startForwardingIncoming
in class SAMv3StreamSession
SAMException
- alwayspublic void stopForwardingIncoming()
stopForwardingIncoming
in class SAMv3StreamSession
public int getListenProtocol()
getListenProtocol
in interface SAMMessageSess
getListenProtocol
in class SAMStreamSession
public int getListenPort()
getListenPort
in interface SAMMessageSess
getListenPort
in class SAMStreamSession
public void close()
close
in interface Closeable
close
in interface AutoCloseable
close
in interface SAMMessageSess
close
in class SAMv3StreamSession
public void disconnected(I2PSession session)
I2PSessionMuxedListener
disconnected
in interface I2PSessionListener
disconnected
in interface I2PSessionMuxedListener
public void errorOccurred(I2PSession session, String message, Throwable error)
I2PSessionMuxedListener
errorOccurred
in interface I2PSessionListener
errorOccurred
in interface I2PSessionMuxedListener
error
- can be null? or not?public void messageAvailable(I2PSession session, int msgId, long size)
I2PSessionMuxedListener
messageAvailable
in interface I2PSessionListener
messageAvailable
in interface I2PSessionMuxedListener
session
- session to notifymsgId
- message number availablesize
- size of the message - why it's a long and not an int is a mysterypublic void messageAvailable(I2PSession session, int msgId, long size, int proto, int fromPort, int toPort)
I2PSessionMuxedListener
messageAvailable
in interface I2PSessionMuxedListener
session
- session to notifymsgId
- message number availablesize
- size of the message - why it's a long and not an int is a mysteryproto
- 1-254 or 0 for unspecifiedfromPort
- 1-65535 or 0 for unspecifiedtoPort
- 1-65535 or 0 for unspecifiedpublic void reportAbuse(I2PSession session, int severity)
I2PSessionMuxedListener
reportAbuse
in interface I2PSessionListener
reportAbuse
in interface I2PSessionMuxedListener
session
- session to report abuse toseverity
- how bad the abuse is