com.realtime.xmpp.examples
Class EchoComponent

java.lang.Object
  |
  +--com.realtime.xmpp.util.RestartingEndpoint
        |
        +--com.realtime.xmpp.dom.DomComponent
              |
              +--com.realtime.xmpp.dom.DomAcceptComponent
                    |
                    +--com.realtime.xmpp.examples.EchoComponent
All Implemented Interfaces:
DomPacketListener, XmppEndpoint

public class EchoComponent
extends DomAcceptComponent
implements DomPacketListener

This is the standard EchoComponent to demonstrate communications with the Jabber server. This component echoes incoming packets back to jabber.

For now, it only works with <message> and <iq> packets. All other packets are dropped.

Message packets simply have their 'to' and 'from' fields reversed. Iq packets have their sub-elements removed, and then replaced by a single <error> element.

All status messages and errors are sent to the console.

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

Nested Class Summary
 
Nested classes inherited from class com.realtime.xmpp.dom.DomAcceptComponent
DomAcceptComponent.AuthenticationManager
 
Field Summary
protected static java.lang.String USAGE
          Command line help string.
 
Fields inherited from class com.realtime.xmpp.dom.DomAcceptComponent
m_authenticationMonitor, m_bAuthenticated, m_sSecret
 
Fields inherited from class com.realtime.xmpp.dom.DomComponent
m_transformer
 
Fields inherited from class com.realtime.xmpp.util.RestartingEndpoint
m_session, m_sessionRestarter, XMPP_REQUEST_TIMEOUT
 
Constructor Summary
EchoComponent(java.lang.String sHost, int nPort, java.lang.String sSecret)
          Create an ACCEPT namespaced component that generates DOM packets from incoming messages.
 
Method Summary
 void incomingPacket(org.dom4j.Element request)
          Echo the incoming packet back to jabber.
static void main(java.lang.String[] argv)
          Command line testing.
 
Methods inherited from class com.realtime.xmpp.dom.DomAcceptComponent
init, start, waitForAuthentication
 
Methods inherited from class com.realtime.xmpp.dom.DomComponent
getDomTransformer, query, send
 
Methods inherited from class com.realtime.xmpp.util.RestartingEndpoint
fastStart, getComponentName, getSession, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

USAGE

protected static final java.lang.String USAGE
Command line help string.

See Also:
Constant Field Values
Constructor Detail

EchoComponent

public EchoComponent(java.lang.String sHost,
                     int nPort,
                     java.lang.String sSecret)
              throws java.security.NoSuchAlgorithmException

Create an ACCEPT namespaced component that generates DOM packets from incoming messages. Uses the secret to handshake with the Jabber server.

Parameters:
sHost - The host name to connect to.
nPort - The server port to connect to.
sSecret - The secret to validate us with the Jabber server.
Throws:
java.security.NoSuchAlgorithmException - Generated when the SHA1 digest is unavailable.
Method Detail

incomingPacket

public void incomingPacket(org.dom4j.Element request)

Echo the incoming packet back to jabber.

For now, only work with message and iq packets. All other packets are dropped.

Message packets simply have their 'to' and 'from' fields reversed. Iq packets have their sub-elements removed, and replaced by a single error element.

Status messages are sent to the console.

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

main

public static void main(java.lang.String[] argv)

Command line testing. If there are no arguments, a help prompt will be generated.

Parameters:
argv - Command line arguments. At least one argument, the secret, is required. The second, and optional, argument is the host name as a DNS resolvable server name. The third parameter is used as the port number to connect to on the host.


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