com.realtime.xmpp.dom
Class DomPacketRouter

java.lang.Object
  |
  +--com.realtime.xmpp.dom.DomPacketRouter
All Implemented Interfaces:
DomPacketListener
Direct Known Subclasses:
GatewayPacketRouter

public class DomPacketRouter
extends java.lang.Object
implements DomPacketListener

Interprets incoming packets and issues callbacks for particular packet types.

Version:
1.0 Copyright © 2002 Real Time Entertainment Group, LLC - All rights reserved.
Author:
Mike Prince

Field Summary
protected  DomComponent m_component
          The Jabber component we are routing packets for.
 
Constructor Summary
DomPacketRouter(DomComponent component)
          Create a router to serve one component.
 
Method Summary
 void doHandshake(org.dom4j.Element packet)
          Accept incoming handshake packets.
 void doInfoQuery(org.dom4j.Element packet)
          Process an incoming IQ packet.
 void doIqRegister(org.dom4j.Element packet, org.dom4j.Element query)
          Process a register query.
 void doIqRegisterSet(org.dom4j.Element packet, org.dom4j.Element query)
          Process a register 'set' query.
 void doIqTime(org.dom4j.Element packet, org.dom4j.Element child)
          Process a time query.
 void doIqVersion(org.dom4j.Element packet, org.dom4j.Element queryIn)
          Process a version query.
 void doMessage(org.dom4j.Element packet)
          Handle a message packet.
 void doPresence(org.dom4j.Element packet)
          Handle a presence packet.
 DomComponent getComponent()
          Provide the component we are serving.
 java.lang.String getGatewayName()
          Provide the name of this gateway for building an iq:version response.
 java.lang.String getGatewayOperatingSystem()
          Provide the operating system of this gateway for building an iq:version response.
 java.lang.String getGatewayVersion()
          Provide the version of this gateway for building an iq:version response.
 Presence getPresence()
          Provide our presence information.
 java.lang.String[] getRegistrationFields()
          Provide the required registration fields.
 java.lang.String getRegistrationInstructions()
          Provide instructions for filling out the registration form.
 void incomingPacket(org.dom4j.Element packet)
          Crack open the incoming packet and route to the appropriate handler.
protected  boolean send(XmppStanza packet)
          Send a response packet and consume any errors.
protected  void sendError(org.dom4j.Element packet, int nError, java.lang.String sReason)
          Send an error in response to the given packet.
 void unhandledIncomingPacket(org.dom4j.Element packet, java.lang.String sReason)
          Signal we couldn't handle the incoming packet because we haven't implemented a handler for the request.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_component

protected DomComponent m_component
The Jabber component we are routing packets for.

Constructor Detail

DomPacketRouter

public DomPacketRouter(DomComponent component)

Create a router to serve one component.

Parameters:
component - The jabber component to route packets for.
Method Detail

getComponent

public DomComponent getComponent()

Provide the component we are serving.

Returns:
The component we are serving.

incomingPacket

public void incomingPacket(org.dom4j.Element packet)

Crack open the incoming packet and route to the appropriate handler. Supports iq, message, and presence packets.

Specified by:
incomingPacket in interface DomPacketListener
Parameters:
packet - The XMPP packet as a DOM element.

unhandledIncomingPacket

public void unhandledIncomingPacket(org.dom4j.Element packet,
                                    java.lang.String sReason)

Signal we couldn't handle the incoming packet because we haven't implemented a handler for the request.

Parameters:
packet - The packet that could not be routed.
sReason - The reason the packet was not routed.

sendError

protected void sendError(org.dom4j.Element packet,
                         int nError,
                         java.lang.String sReason)

Send an error in response to the given packet.

Parameters:
packet - The packet to send an error in response to.
nError - The error code.
sReason - An optional message giving the reason the packet failed.

send

protected boolean send(XmppStanza packet)

Send a response packet and consume any errors.

* @param packet The packet to send.

Returns:
True if the packet was sent. False if there were transmission errors.

doHandshake

public void doHandshake(org.dom4j.Element packet)

Accept incoming handshake packets. These are usually responses to accept components sending a handshake, and as such should be ignored.

Parameters:
packet - Handshake packet.

doInfoQuery

public void doInfoQuery(org.dom4j.Element packet)

Process an incoming IQ packet.

Parameters:
packet - The incoming packet to process.

doIqRegister

public void doIqRegister(org.dom4j.Element packet,
                         org.dom4j.Element query)

Process a register query.

Parameters:
packet - The root packet.
query - The packets query child element.

doIqRegisterSet

public void doIqRegisterSet(org.dom4j.Element packet,
                            org.dom4j.Element query)

Process a register 'set' query.

Parameters:
packet - The root packet.
query - The packets query child element.

getRegistrationFields

public java.lang.String[] getRegistrationFields()

Provide the required registration fields.

Returns:
An array of strings representing required registration fields.

getRegistrationInstructions

public java.lang.String getRegistrationInstructions()

Provide instructions for filling out the registration form.

Returns:
Instructions for filling out the registration form.

doIqVersion

public void doIqVersion(org.dom4j.Element packet,
                        org.dom4j.Element queryIn)

Process a version query.

Parameters:
packet - The root packet.
queryIn - The packets query child element.

getGatewayName

public java.lang.String getGatewayName()

Provide the name of this gateway for building an iq:version response.

Returns:
The name of this gateway.

getGatewayVersion

public java.lang.String getGatewayVersion()

Provide the version of this gateway for building an iq:version response.

Returns:
The version of this gateway.

getGatewayOperatingSystem

public java.lang.String getGatewayOperatingSystem()

Provide the operating system of this gateway for building an iq:version response.

Returns:
The operating system this gateway in running on.

doIqTime

public void doIqTime(org.dom4j.Element packet,
                     org.dom4j.Element child)

Process a time query. Being nice, we provide an implementation :)

Parameters:
packet - The root packet.
child - The packets query child element.

doMessage

public void doMessage(org.dom4j.Element packet)

Handle a message packet.

Parameters:
packet - A message packet.

doPresence

public void doPresence(org.dom4j.Element packet)

Handle a presence packet.

Parameters:
packet - A presence packet.

getPresence

public Presence getPresence()

Provide our presence information.

* @return Our presence info.



Copyright © 2002,2003 Real Time Entertainment Group, LLC. All Rights Reserved.