View Javadoc

1   //////////////////////////////////////////////////////////////////////////////
2   // dexterIM - Instant Messaging Framework
3   // Copyright (C) 2003  Christoph Walcher
4   //
5   // This program is free software; you can redistribute it and/or modify
6   // it under the terms of the GNU General Public License as published by
7   // the Free Software Foundation; either version 2 of the License, or
8   // (at your option) any later version.
9   //
10  // This program is distributed in the hope that it will be useful,
11  // but WITHOUT ANY WARRANTY; without even the implied warranty of
12  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  // GNU General Public License for more details.
14  //
15  // You should have received a copy of the GNU General Public License
16  // along with this program; if not, write to the Free Software
17  // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  //////////////////////////////////////////////////////////////////////////////
19  package net.sf.dexterim.msn.message;
20  
21  import net.sf.dexterim.msn.MsnConnection;
22  
23  /***
24   *
25   * @author  Christoph Walcher
26   */
27  public class ReferMessage extends SingleLineMessage {
28    /*** Creates a new instance of ReferMessage */
29    public ReferMessage() {
30    }
31  
32    /*** Parses Refer Messages. Two types of Refer Messages are used in MSN Messenger
33    * <ul>
34    * <li> <b>For Switchboard: </b> XFR 10 SB 64.4.12.193:1863 CKI 16925950.1016955577.17693
35    * <li> <b>For Connecting:</b> XFR 2 NS 207.46.106.145:1863 0 207.46.104.20:1863
36    * </ul>
37    */
38    public net.sf.dexterim.msn.message.MsnMessage addLine(String line)
39      throws net.sf.dexterim.msn.message.MessageFormatException {
40      java.util.StringTokenizer st = new java.util.StringTokenizer(line);
41  
42      // Skip Command and transmissionID
43      st.nextToken();
44      st.nextToken();
45  
46      String command = st.nextToken();
47  
48      if ("SB".equals(command)) {
49        SwitchBoardMessage sbMessage = new SwitchBoardMessage();
50  
51        return sbMessage.addLine(line);
52      }
53      else if ("NS".equals(command)) {
54        NewServerMessage nsMessage = new NewServerMessage();
55  
56        return nsMessage.addLine(line);
57      }
58  
59      throw new net.sf.dexterim.msn.message.MessageFormatException(
60        "Not a Switchboard nor a NewServerMessage!");
61    }
62  
63    /* (non-Javadoc)
64     * @see net.sf.dexterim.msn.message.MsnMessage#process(net.sf.dexterim.msn.MsnConnection)
65     */
66    public void process(MsnConnection connection) {
67      // TODO Auto-generated method stub
68      
69    }
70  }