1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.xnap.plugin.opennap.net.msg.server;
21
22 import org.xnap.net.NetHelper;
23 import org.xnap.plugin.opennap.user.OpenNapUser;
24 import org.xnap.util.*;
25
26 public class SearchResponseMessage extends ServerMessage {
27
28
29
30 public static final int TYPE = 201;
31
32
33
34 public String filename;
35 public String md5;
36 public long filesize;
37 public int bitrate;
38 public int frequency;
39 public int length;
40 public String nick;
41 public String ip;
42 public int linkSpeed;
43 public int weight;
44 public int queuePos;
45 public String clientInfo;
46
47
48
49 public SearchResponseMessage(String data) throws InvalidMessageException
50 {
51 super(TYPE, data, 9);
52 }
53
54
55
56 protected void parse(QuotedStringTokenizer t)
57 {
58 filename = t.nextToken();
59 md5 = t.nextToken();
60 filesize = Long.parseLong(t.nextToken());
61 bitrate = Integer.parseInt(t.nextToken());
62 frequency = Integer.parseInt(t.nextToken());
63 length = Integer.parseInt(t.nextToken());
64 nick = t.nextToken();
65 ip = NetHelper.toIP(t.nextToken());
66 linkSpeed = Integer.parseInt(t.nextToken());
67
68 weight = 0;
69 queuePos = -1;
70 if (t.countTokens() >= 2) {
71 try {
72
73 queuePos = Integer.parseInt(t.nextToken());
74 }
75 catch (NumberFormatException e) {
76 }
77 clientInfo = t.nextToken();
78 }
79 else if (t.hasMoreTokens()) {
80 weight = Integer.parseInt(t.nextToken());
81 }
82 }
83
84 public void received()
85 {
86 OpenNapUser user = server.getUser(nick);
87 user.setHost(ip);
88 user.setLinkSpeed(linkSpeed);
89 if (clientInfo != null) {
90 user.setClientInfo(clientInfo);
91 }
92 }
93
94 }
95