1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package net.sf.dexterim.msn.message;
20
21 import java.util.StringTokenizer;
22
23 import net.sf.dexterim.msn.MsnConnection;
24 import net.sf.dexterim.msn.entity.SwitchBoardServer;
25
26 /***
27 * Description of the Class
28 *
29 *@author christoph
30 */
31 public class SwitchBoardMessage extends SingleLineMessage {
32 private String ip;
33 private int port;
34 private String cki;
35 private String id;
36
37 /***
38 * Constructor for the SwitchBoardMessage object
39 */
40 public SwitchBoardMessage() {
41 }
42
43 public SwitchBoardMessage(String ip, int port, String cki) {
44 this.ip = ip;
45 this.port = port;
46 this.cki = cki;
47 }
48
49 /***
50 * Gets the messageCommand attribute of the SwitchBoardMessage object
51 *
52 *@return The messageCommand value
53 */
54 public String getMessageCommand() {
55 return MsnMessageFactory.CMD_REFER;
56 }
57
58 public SwitchBoardServer getSwitchBoardServer() {
59 return new SwitchBoardServer(ip, port, cki);
60 }
61
62 /***
63 * Adds a feature to the Line attribute of the SwitchBoardMessage object
64 *
65 *@param line The feature to be added to the Line
66 * attribute
67 *@return Description of the Return Value
68 *@exception MessageFormatException Description of the Exception
69 */
70 public MsnMessage addLine(String line) throws MessageFormatException {
71 try {
72 StringTokenizer st = new StringTokenizer(line);
73
74 st.nextToken();
75
76 this.id = st.nextToken();
77
78 st.nextToken();
79
80 String s = st.nextToken();
81
82 int i = s.indexOf(":");
83
84 if (i < 0) {
85 throw new MessageFormatException("Unexpected Reply, switchboard port and IP are missing");
86 }
87
88 this.ip = s.substring(0, i);
89
90 this.port = Integer.parseInt(s.substring(i + 1));
91
92 st.nextToken();
93
94 this.cki = st.nextToken();
95
96 return this;
97 }
98 catch (Exception ex) {
99 throw new MessageFormatException(ex);
100 }
101 }
102
103 /*** Getter for property id.
104 * @return Value of property id.
105 *
106 */
107 public java.lang.String getId() {
108 return id;
109 }
110
111
112
113
114 public void process(MsnConnection connection) {
115
116
117 }
118 }