Steven Shaughnessy | 13 Jan 2006 03:56

Using jso library to build an xmpp server

 

I’m looking for a library to server side xmpp requests.  Is this something that the jso library would be well suited for?

 

I played around with the EchoClient and EchoServer.  I assume that XPathListener implementations would be used on the server side to process in coming packets in much the same way EchoClient does.  However, It appears that the EchoServer example is very simple and does not wire any XPathListeners.  Consequently the EchoClient cannot be executed against the EchoServer without hanging.

 

Did I miss something?

 

If not, can someone help a poor newbie and provide a simple update to EchoServer that can process the packets sent by EchoClient?  I tried to do this, but my XPathListener was never called for the login from the EchoClient:

 

<iq xmlns='jabber:client' id='auth-1' to='pcl-shaughnessy' type='get'>

            <query xmlns='jabber:iq:auth'>

                        <username>pcl-shaughnessy</username>

                        <resource>cmc</resource>

            </query>

</iq>

 

Thanks,

 

-Steve

_______________________________________________
jso-devel mailing list
jso-devel <at> jabberstudio.org
http://mail.jabber.org/mailman/listinfo/jso-devel
Steven Shaughnessy | 13 Jan 2006 04:33

RE: Using jso library to build an xmpp server

Here are some more specifics.

 

I execute “EchoServer pcl-shaughnessy 5222”

I execute “EchoClient sshaughnessy <at> pcl-shaughnessy/cmc dummy pcl-shaughnessy 5222"

 

This is output from the client when it attempts to login:

 

37766 [main] ERROR EchoClient$EventLogger  - sent packet: <iq xmlns='jabber:client' id='auth-1' to='pcl-shaughnessy' type='get'><query xmlns='jabber:iq:auth'><username>sshaughnessy</username><resource>cmc</resource></query></iq>

 

I have pasted my change to EchoServer.java at the end of this mail.  I added a setupIQListeners() method and call it from the end of the constructor.

 

However the “packetTransferred()” event handler is never called.

 

Any help would be appreciated.

 

-Steve

 

=========================================================

 

        //Constructors

        public Session(SocketChannel sc) throws StreamException {

            JSOImplementation   jso = JSOImplementation.getInstance();

           

            _Conn = jso.createStream(Utilities.CLIENT_NAMESPACE);

           

            _Conn.addStreamStatusListener(new StatusMonitor());

            _Conn.addStreamStatusListener(this);

            _Conn.connect(new ChannelStreamSource(sc));

            setupIQListeners();

        }

        private void setupIQListeners() {

            Logger          log = obtainLogger();

            Stream stream = getConnection();

            StreamDataFactory sdf = stream.getDataFactory();

            XPathListener xpl;

            PacketListenerRelay dispatch = new PacketListenerRelay();

 

            try {

              xpl = new XPathListener(sdf, "app:iq[ <at> type='get']/auth:*",

                  new PacketListener() {

                    public void packetTransferred(PacketEvent evt) {

                      InfoQuery in = (InfoQuery) evt.getData();

                      InfoQuery out = (InfoQuery) in.copy();

 

                      evt.setHandled(true);

 

                      // Prepare IQ

                      out.reset();

                      out.setID(in.getID());

                      out.setTo(in.getFrom());

                      out.setType(InfoQuery.RESULT);

 

// Do somthing here...                     

//                      processAuth(in, out);

                      enque(out);

                    }

                  });

              dispatch.addPacketListener(xpl);

            }

        catch (SAXPathException saxpe) {

            log.error("SAXPathException", saxpe);

        }

    }

_______________________________________________
jso-devel mailing list
jso-devel <at> jabberstudio.org
http://mail.jabber.org/mailman/listinfo/jso-devel
Steven Shaughnessy | 13 Jan 2006 19:04

RE: Using jso library to build an xmpp server

I found a couple problems and I can now receive server side packets.

 

-Steve

 

From: jso-devel-bounces <at> jabberstudio.org [mailto:jso-devel-bounces <at> jabberstudio.org] On Behalf Of Steven Shaughnessy
Sent: Thursday, January 12, 2006 7:34 PM
To: jso-devel <at> jabberstudio.org
Subject: RE: [JSO-DEVEL] Using jso library to build an xmpp server

 

Here are some more specifics.

 

I execute “EchoServer pcl-shaughnessy 5222”

I execute “EchoClient sshaughnessy <at> pcl-shaughnessy/cmc dummy pcl-shaughnessy 5222"

 

This is output from the client when it attempts to login:

 

37766 [main] ERROR EchoClient$EventLogger  - sent packet: <iq xmlns='jabber:client' id='auth-1' to='pcl-shaughnessy' type='get'><query xmlns='jabber:iq:auth'><username>sshaughnessy</username><resource>cmc</resource></query></iq>

 

I have pasted my change to EchoServer.java at the end of this mail.  I added a setupIQListeners() method and call it from the end of the constructor.

 

However the “packetTransferred()” event handler is never called.

 

Any help would be appreciated.

 

-Steve

 

=========================================================

 

        //Constructors

        public Session(SocketChannel sc) throws StreamException {

            JSOImplementation   jso = JSOImplementation.getInstance();

           

            _Conn = jso.createStream(Utilities.CLIENT_NAMESPACE);

           

            _Conn.addStreamStatusListener(new StatusMonitor());

            _Conn.addStreamStatusListener(this);

            _Conn.connect(new ChannelStreamSource(sc));

            setupIQListeners();

        }

        private void setupIQListeners() {

            Logger          log = obtainLogger();

            Stream stream = getConnection();

            StreamDataFactory sdf = stream.getDataFactory();

            XPathListener xpl;

            PacketListenerRelay dispatch = new PacketListenerRelay();

 

            try {

              xpl = new XPathListener(sdf, "app:iq[ <at> type='get']/auth:*",

                  new PacketListener() {

                    public void packetTransferred(PacketEvent evt) {

                      InfoQuery in = (InfoQuery) evt.getData();

                      InfoQuery out = (InfoQuery) in.copy();

 

                      evt.setHandled(true);

 

                      // Prepare IQ

                      out.reset();

                      out.setID(in.getID());

                      out.setTo(in.getFrom());

                      out.setType(InfoQuery.RESULT);

 

// Do somthing here...                     

//                      processAuth(in, out);

                      enque(out);

                    }

                  });

              dispatch.addPacketListener(xpl);

            }

        catch (SAXPathException saxpe) {

            log.error("SAXPathException", saxpe);

        }

    }

_______________________________________________
jso-devel mailing list
jso-devel <at> jabberstudio.org
http://mail.jabber.org/mailman/listinfo/jso-devel

Gmane