source: java-rpg-portal/PortalThread.java@ 0b6a4fe

Last change on this file since 0b6a4fe was 0b6a4fe, checked in by dportnoy <dmp1488@…>, 17 years ago

[svn r8]

  • Property mode set to 100644
File size: 2.0 KB
Line 
1import javax.swing.JOptionPane;
2
3
4public class PortalThread extends Connection {
5 private LostHavenPortal main;
6
7 public PortalThread(String ip, int port, LostHavenPortal main) {
8 super(ip, port, "PortalThread");
9
10 this.main = main;
11 }
12
13 protected void processMessage(MessageType type, String input) {
14 Player p;
15 int id;
16 String name;
17 boolean online;
18
19 switch(type) {
20 case Info:
21 if(input.equals("started")) {
22 main.lblServerStatus.setText("online");
23 }else if(input.equals("stopped")) {
24 main.lblServerStatus.setText("offline");
25 }
26 break;
27 case Registered:
28 id = Integer.parseInt(input.substring(0, input.indexOf(";")));
29 input = input.substring(input.indexOf(";")+1);
30 name = input.substring(0, input.indexOf(";"));
31 input = input.substring(input.indexOf(";")+1);
32 online = input.equals("true");
33
34 p = new Player(id, name, "");
35
36 if(!main.registered.containsKey(name)) {
37 main.addRegList(name, p);
38 if(online) {
39 main.addOnlineList(name);
40 }
41 }
42 break;
43 }
44 }
45
46 protected void connectionStart() {
47
48 }
49
50 protected void connectionSuccess() {
51 main.lblConnectionStatus.setText("connected");
52 sendMessage(MessageType.Admin, "");
53 }
54
55 protected void connectionFailure() {
56 JOptionPane.showMessageDialog(main, "Connection could not be established.");
57 }
58
59 protected void connectionBreak() {
60 JOptionPane.showMessageDialog(main, "Your connection was interrupted");
61 }
62
63 protected void peerDisconnect() {
64 JOptionPane.showMessageDialog(main, "The server disconnected");
65 }
66
67 protected void connectionEnd() {
68 main.registered.clear();
69 main.orderedReg.clear();
70 main.orderedOnline.clear();
71 main.lblConnectionStatus.setText("disconnected");
72 main.lblServerStatus.setText("not available");
73 main.updateGui();
74 }
75}
Note: See TracBrowser for help on using the repository browser.