Package net.i2p.sam

Class PrimarySession

    • Method Detail

      • remove

        public String remove​(String nick,
                             Properties props)
        Remove a session
        Parameters:
        props - ignored, may be null
        Returns:
        null for success, or error message
      • receiveDatagramBytes

        public void receiveDatagramBytes​(Destination sender,
                                         byte[] data,
                                         int proto,
                                         int fromPort,
                                         int toPort)
                                  throws IOException
        Description copied from interface: SAMDatagramReceiver
        Send a byte array to a SAM client.
        Specified by:
        receiveDatagramBytes in interface SAMDatagramReceiver
        Parameters:
        sender - Destination
        data - Byte array to be received
        proto - I2CP protocol
        fromPort - I2CP from port
        toPort - I2CP to port
        Throws:
        IOException - always
      • receiveRawBytes

        public void receiveRawBytes​(byte[] data,
                                    int proto,
                                    int fromPort,
                                    int toPort)
                             throws IOException
        Description copied from interface: SAMRawReceiver
        Send a byte array to a SAM client, without informations regarding the sender.
        Specified by:
        receiveRawBytes in interface SAMRawReceiver
        Parameters:
        data - Byte array to be received
        proto - I2CP protocol
        fromPort - I2CP from port
        toPort - I2CP to port
        Throws:
        IOException - always
      • connect

        public void connect​(SAMv3Handler handler,
                            String dest,
                            Properties props)
                     throws I2PException
        Description copied from class: SAMv3StreamSession
        Connect the SAM STREAM session to the specified Destination for a single connection, using the socket stolen from the handler.
        Overrides:
        connect in class SAMv3StreamSession
        Parameters:
        handler - The handler that communicates with the requesting client
        dest - Base64-encoded Destination to connect to
        props - Options to be used for connection
        Throws:
        I2PException - always
      • accept

        public void accept​(SAMv3Handler handler,
                           boolean verbose)
                    throws SAMException
        Description copied from class: SAMv3StreamSession
        Accept a single incoming STREAM on the socket stolen from the handler. As of version 3.2 (0.9.24), multiple simultaneous accepts are allowed. Accepts and forwarding may not be done at the same time.
        Overrides:
        accept in class SAMv3StreamSession
        Parameters:
        handler - The handler that communicates with the requesting client
        verbose - 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 socket
        Throws:
        SAMException - always
      • messageAvailable

        public void messageAvailable​(I2PSession session,
                                     int msgId,
                                     long size)
        Description copied from interface: I2PSessionMuxedListener
        Will be called only if you register via setSessionListener() or addSessionListener(). And if you are doing that, just use I2PSessionListener. If you register via addSessionListener(), this will be called only for the proto(s) and toport(s) you register for. After this is called, the client should call receiveMessage(msgId). There is currently no method for the client to reject the message. If the client does not call receiveMessage() within a timeout period (currently 30 seconds), the session will delete the message and log an error.
        Specified by:
        messageAvailable in interface I2PSessionListener
        Specified by:
        messageAvailable in interface I2PSessionMuxedListener
        Parameters:
        session - session to notify
        msgId - message number available
        size - size of the message - why it's a long and not an int is a mystery
      • messageAvailable

        public void messageAvailable​(I2PSession session,
                                     int msgId,
                                     long size,
                                     int proto,
                                     int fromPort,
                                     int toPort)
        Description copied from interface: I2PSessionMuxedListener
        Instruct the client that the given session has received a message Will be called only if you register via addMuxedSessionListener(). Will be called only for the proto(s) and toport(s) you register for. After this is called, the client should call receiveMessage(msgId). There is currently no method for the client to reject the message. If the client does not call receiveMessage() within a timeout period (currently 30 seconds), the session will delete the message and log an error. Only one listener is called for a given message, even if more than one have registered. See I2PSessionDemultiplexer for details.
        Specified by:
        messageAvailable in interface I2PSessionMuxedListener
        Parameters:
        session - session to notify
        msgId - message number available
        size - size of the message - why it's a long and not an int is a mystery
        proto - 1-254 or 0 for unspecified
        fromPort - 1-65535 or 0 for unspecified
        toPort - 1-65535 or 0 for unspecified
        Since:
        0.9.24
      • reportAbuse

        public void reportAbuse​(I2PSession session,
                                int severity)
        Description copied from interface: I2PSessionMuxedListener
        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. All registered listeners will be called. Unused. Not fully implemented.
        Specified by:
        reportAbuse in interface I2PSessionListener
        Specified by:
        reportAbuse in interface I2PSessionMuxedListener
        Parameters:
        session - session to report abuse to
        severity - how bad the abuse is