1 11 12 package org.jivesoftware.messenger.net; 13 14 import org.dom4j.Element; 15 import org.jivesoftware.messenger.ClientSession; 16 import org.jivesoftware.messenger.PacketRouter; 17 import org.jivesoftware.messenger.auth.UnauthorizedException; 18 import org.xmlpull.v1.XmlPullParserException; 19 import org.xmpp.packet.IQ; 20 import org.xmpp.packet.Message; 21 import org.xmpp.packet.Presence; 22 23 import java.io.IOException ; 24 import java.net.Socket ; 25 26 33 public class ClientSocketReader extends SocketReader { 34 35 public ClientSocketReader(PacketRouter router, String serverName, Socket socket, 36 SocketConnection connection) { 37 super(router, serverName, socket, connection); 38 } 39 40 protected void processIQ(IQ packet) throws UnauthorizedException { 41 packet.setFrom(session.getAddress()); 43 super.processIQ(packet); 44 } 45 46 protected void processPresence(Presence packet) throws UnauthorizedException { 47 packet.setFrom(session.getAddress()); 49 super.processPresence(packet); 50 } 51 52 protected void processMessage(Message packet) throws UnauthorizedException { 53 packet.setFrom(session.getAddress()); 55 super.processMessage(packet); 56 } 57 58 65 protected boolean processUnknowPacket(Element doc) { 66 return false; 67 } 68 69 boolean createSession(String namespace) throws UnauthorizedException, XmlPullParserException, 70 IOException { 71 if ("jabber:client".equals(namespace)) { 72 session = ClientSession.createSession(serverName, reader, connection); 74 return true; 75 } 76 return false; 77 } 78 79 } 80 | Popular Tags |