public abstract class SocketReader extends Object implements Runnable
Session
based on the defined namespace in the
stream element and will then keep reading and routing the received packets.Modifier and Type | Field and Description |
---|---|
protected SocketConnection |
connection
Reference to the physical connection.
|
protected boolean |
directTLS
Indicates if sockets initially will be plain text (false), or ecnrypted (true).
|
protected boolean |
open |
protected String |
serverName
Server name for which we are attending clients.
|
protected LocalSession |
session
Session associated with the socket reader.
|
Constructor and Description |
---|
SocketReader(PacketRouter router,
RoutingTable routingTable,
String serverName,
Socket socket,
SocketConnection connection,
boolean useBlockingMode,
boolean directTLS)
Creates a dedicated reader for a socket.
|
Modifier and Type | Method and Description |
---|---|
protected void |
createSession()
Uses the XPP to grab the opening stream tag and create an active session
object.
|
String |
getExtraNamespaces() |
protected void |
process(org.dom4j.Element doc) |
protected void |
processIQ(org.xmpp.packet.IQ packet)
Process the received IQ packet.
|
protected void |
processMessage(org.xmpp.packet.Message packet)
Process the received Message packet.
|
protected void |
processPresence(org.xmpp.packet.Presence packet)
Process the received Presence packet.
|
void |
run()
A dedicated thread loop for reading the stream and sending incoming
packets to the appropriate router.
|
protected void |
shutdown()
Notification message indicating that the SocketReader is shutting down.
|
protected LocalSession session
protected SocketConnection connection
protected String serverName
protected boolean directTLS
protected boolean open
public SocketReader(PacketRouter router, RoutingTable routingTable, String serverName, Socket socket, SocketConnection connection, boolean useBlockingMode, boolean directTLS)
router
- the router for sending packets that were read.routingTable
- the table that keeps routes to registered services.serverName
- the name of the server this socket is working for.socket
- the socket to read from.connection
- the connection being read.useBlockingMode
- true means that the server will use a thread per connection.directTLS
- false means that the socket initially is a plaintext connection.public void run()
protected void processIQ(org.xmpp.packet.IQ packet) throws UnauthorizedException
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.
packet
- the received packet.UnauthorizedException
- if the connection required security but was not secured.protected void processPresence(org.xmpp.packet.Presence packet) throws UnauthorizedException
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.
packet
- the received packet.UnauthorizedException
- if the connection required security but was not secured.protected void processMessage(org.xmpp.packet.Message packet) throws UnauthorizedException
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.
packet
- the received packet.UnauthorizedException
- if the connection required security but was not secured.protected void createSession() throws UnauthorizedException, org.xmlpull.v1.XmlPullParserException, IOException
UnauthorizedException
- if the connection required security but was not secured.org.xmlpull.v1.XmlPullParserException
- if there was an XML error while creating the session.IOException
- if an IO error occured while creating the session.protected void shutdown()
public String getExtraNamespaces()
Copyright © 2003–2019 Ignite Realtime. All rights reserved.