Class StanzaHandler

    • Field Detail

      • CHARSET

        protected static String CHARSET
        The utf-8 charset for decoding and encoding Jabber packet streams.
      • session

        protected LocalSession session
        Session associated with the socket reader.
    • Constructor Detail

      • StanzaHandler

        public StanzaHandler​(PacketRouter router,
                             Connection connection)
        Creates a dedicated reader for a socket.
        Parameters:
        router - the router for sending packets that were read.
        connection - the connection being read.
    • Method Detail

      • setSession

        public void setSession​(LocalSession session)
      • processIQ

        protected void processIQ​(org.xmpp.packet.IQ packet)
                          throws UnauthorizedException
        Process the received IQ packet. Registered PacketInterceptor will be invoked before and after the packet was routed.

        Subclasses may redefine this method for different reasons such as modifying the sender of the packet to avoid spoofing, rejecting the packet or even process the packet in another thread.

        Parameters:
        packet - the received packet.
        Throws:
        UnauthorizedException - if service is not available to sender.
      • processPresence

        protected void processPresence​(org.xmpp.packet.Presence packet)
                                throws UnauthorizedException
        Process the received Presence packet. Registered PacketInterceptor will be invoked before and after the packet was routed.

        Subclasses may redefine this method for different reasons such as modifying the sender of the packet to avoid spoofing, rejecting the packet or even process the packet in another thread.

        Parameters:
        packet - the received packet.
        Throws:
        UnauthorizedException - if service is not available to sender.
      • processMessage

        protected void processMessage​(org.xmpp.packet.Message packet)
                               throws UnauthorizedException
        Process the received Message packet. Registered PacketInterceptor will be invoked before and after the packet was routed.

        Subclasses may redefine this method for different reasons such as modifying the sender of the packet to avoid spoofing, rejecting the packet or even process the packet in another thread.

        Parameters:
        packet - the received packet.
        Throws:
        UnauthorizedException - if service is not available to sender.
      • createSession

        protected void createSession​(org.xmlpull.v1.XmlPullParser xpp)
                              throws org.xmlpull.v1.XmlPullParserException,
                                     IOException
        Uses the XPP to grab the opening stream tag and create an active session object. The session to create will depend on the sent namespace. In all cases, the method obtains the opening stream tag, checks for errors, and either creates a session or returns an error and kills the connection. If the connection remains open, the XPP will be set to be ready for the first packet. A call to next() should result in an START_TAG state with the first packet in the stream.
        Parameters:
        xpp - the pull parser
        Throws:
        org.xmlpull.v1.XmlPullParserException - if an exception occurs reading from the pull parser
        IOException - if an IO exception occurs reading from the pull parser
      • getAddress

        public org.xmpp.packet.JID getAddress()
        Obtain the address of the XMPP entity for which this StanzaHandler handles stanzas. Note that the value that is returned for this method can change over time. For example, if no session has been established yet, this method will return null, or, if resource binding occurs, the returned value might change. Values obtained from this method are therefore best not cached.
        Returns:
        The address of the XMPP entity for.