KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jivesoftware > messenger > net > ComponentSocketReader


1 /**
2  * $RCSfile: ComponentSocketReader.java,v $
3  * $Revision: 1.2 $
4  * $Date: 2005/06/24 04:58:50 $
5  *
6  * Copyright (C) 2004 Jive Software. All rights reserved.
7  *
8  * This software is published under the terms of the GNU Public License (GPL),
9  * a copy of which is included in this distribution.
10  */

11
12 package org.jivesoftware.messenger.net;
13
14 import org.dom4j.Element;
15 import org.jivesoftware.messenger.component.ComponentSession;
16 import org.jivesoftware.messenger.PacketRouter;
17 import org.jivesoftware.messenger.auth.UnauthorizedException;
18 import org.xmlpull.v1.XmlPullParserException;
19
20 import java.io.IOException JavaDoc;
21 import java.net.Socket JavaDoc;
22
23 /**
24  * A SocketReader specialized for component connections. This reader will be used when the open
25  * stream contains a jabber:component:accept namespace.
26  *
27  * @author Gaston Dombiak
28  */

29 public class ComponentSocketReader extends SocketReader {
30
31     public ComponentSocketReader(PacketRouter router, String JavaDoc serverName, Socket JavaDoc socket,
32             SocketConnection connection) {
33         super(router, serverName, socket, connection);
34     }
35
36     /**
37      * Only packets of type Message, Presence and IQ can be processed by this class. Any other
38      * type of packet is unknown and thus rejected generating the connection to be closed.
39      *
40      * @param doc the unknown DOM element that was received
41      * @return always false.
42      */

43     protected boolean processUnknowPacket(Element doc) {
44         return false;
45     }
46
47     boolean createSession(String JavaDoc namespace) throws UnauthorizedException, XmlPullParserException,
48             IOException JavaDoc {
49         if ("jabber:component:accept".equals(namespace)) {
50             // The connected client is a component so create a ComponentSession
51
session = ComponentSession.createSession(serverName, reader, connection);
52             return true;
53         }
54         return false;
55     }
56 }
57
Popular Tags