author | Medo <smaxein@googlemail.com> |
Tue, 17 Jul 2012 23:06:20 +0200 | |
changeset 7334 | 66a10ae88457 |
parent 7332 | 3f2e130f9715 |
child 7342 | 0e29eec2df5c |
permissions | -rw-r--r-- |
7332
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1 |
package org.hedgewars.hedgeroid.netplay; |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
2 |
|
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
3 |
import java.io.File; |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
4 |
import java.io.IOException; |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
5 |
|
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
6 |
import org.hedgewars.hedgeroid.Utils; |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
7 |
import org.hedgewars.hedgeroid.netplay.JnaFrontlib.IntStrCallback; |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
8 |
import org.hedgewars.hedgeroid.netplay.JnaFrontlib.MetaschemePtr; |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
9 |
import org.hedgewars.hedgeroid.netplay.JnaFrontlib.NetconnPtr; |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
10 |
import org.hedgewars.hedgeroid.netplay.JnaFrontlib.StrCallback; |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
11 |
import org.hedgewars.hedgeroid.netplay.JnaFrontlib.StrStrCallback; |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
12 |
|
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
13 |
import com.sun.jna.Pointer; |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
14 |
|
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
15 |
import android.content.Context; |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
16 |
import android.util.Log; |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
17 |
|
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
18 |
/** |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
19 |
* Java-wrapper for the C netconn type. Apart from turning netconn into a more Java-like |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
20 |
* object with methods, this also handles some of the problems of C <-> Java interop (e.g. |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
21 |
* ensuring that callback objects don't get garbage collected). |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
22 |
*/ |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
23 |
public class Netconn { |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
24 |
private static final JnaFrontlib FLIB = Flib.INSTANCE; |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
25 |
private static final String DEFAULT_SERVER = "140.247.62.101"; |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
26 |
private static final int DEFAULT_PORT = 46631; |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
27 |
|
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
28 |
private NetconnPtr conn; |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
29 |
private String playerName; |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
30 |
|
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
31 |
public final PlayerList playerList = new PlayerList(); |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
32 |
public final MessageLog lobbyLog; |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
33 |
public final MessageLog roomLog; |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
34 |
|
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
35 |
private StrCallback lobbyJoinCb = new StrCallback() { |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
36 |
public void callback(Pointer context, String arg1) { |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
37 |
playerList.addPlayer(arg1); |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
38 |
lobbyLog.appendPlayerJoin(arg1); |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
39 |
} |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
40 |
}; |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
41 |
|
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
42 |
private StrStrCallback lobbyLeaveCb = new StrStrCallback() { |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
43 |
public void callback(Pointer context, String name, String msg) { |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
44 |
playerList.removePlayer(name); |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
45 |
lobbyLog.appendPlayerLeave(name, msg); |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
46 |
} |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
47 |
}; |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
48 |
|
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
49 |
private StrStrCallback chatCb = new StrStrCallback() { |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
50 |
public void callback(Pointer context, String name, String msg) { |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
51 |
getCurrentLog().appendChat(name, msg); |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
52 |
} |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
53 |
}; |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
54 |
|
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
55 |
private IntStrCallback messageCb = new IntStrCallback() { |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
56 |
public void callback(Pointer context, int type, String msg) { |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
57 |
getCurrentLog().appendMessage(type, msg); |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
58 |
} |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
59 |
}; |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
60 |
|
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
61 |
/** |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
62 |
* Connect to the official Hedgewars server. |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
63 |
* |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
64 |
* @throws IOException if the metascheme file can't be read or the connection to the server fails |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
65 |
*/ |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
66 |
public Netconn(Context context, String playerName) throws IOException { |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
67 |
this(context, playerName, DEFAULT_SERVER, DEFAULT_PORT); |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
68 |
} |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
69 |
|
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
70 |
/** |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
71 |
* Connect to the server with the given hostname and port |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
72 |
* |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
73 |
* @throws IOException if the metascheme file can't be read or the connection to the server fails |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
74 |
*/ |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
75 |
public Netconn(Context context, String playerName, String host, int port) throws IOException { |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
76 |
if(playerName == null) { |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
77 |
playerName = "Player"; |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
78 |
} |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
79 |
this.playerName = playerName; |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
80 |
this.lobbyLog = new MessageLog(context); |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
81 |
this.roomLog = new MessageLog(context); |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
82 |
|
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
83 |
MetaschemePtr meta = null; |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
84 |
File dataPath = Utils.getDataPathFile(context); |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
85 |
try { |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
86 |
String metaschemePath = new File(dataPath, "metasettings.ini").getAbsolutePath(); |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
87 |
meta = FLIB.flib_metascheme_from_ini(metaschemePath); |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
88 |
if(meta == null) { |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
89 |
throw new IOException("Missing metascheme"); |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
90 |
} |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
91 |
conn = FLIB.flib_netconn_create(playerName, meta, dataPath.getAbsolutePath(), host, port); |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
92 |
if(conn == null) { |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
93 |
throw new IOException("Unable to connect to the server"); |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
94 |
} |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
95 |
FLIB.flib_netconn_onLobbyJoin(conn, lobbyJoinCb, null); |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
96 |
FLIB.flib_netconn_onLobbyLeave(conn, lobbyLeaveCb, null); |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
97 |
FLIB.flib_netconn_onChat(conn, chatCb, null); |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
98 |
FLIB.flib_netconn_onMessage(conn, messageCb, null); |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
99 |
} finally { |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
100 |
FLIB.flib_metascheme_release(meta); |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
101 |
} |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
102 |
} |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
103 |
|
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
104 |
public void disconnect() { |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
105 |
if(conn != null) { |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
106 |
FLIB.flib_netconn_send_quit(conn, "User quit"); |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
107 |
FLIB.flib_netconn_destroy(conn); |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
108 |
conn = null; |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
109 |
} |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
110 |
} |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
111 |
|
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
112 |
public void tick() { |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
113 |
FLIB.flib_netconn_tick(conn); |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
114 |
} |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
115 |
|
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
116 |
public void sendChat(String s) { |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
117 |
FLIB.flib_netconn_send_chat(conn, s); |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
118 |
if(FLIB.flib_netconn_is_in_room_context(conn)) { |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
119 |
roomLog.appendChat(playerName, s); |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
120 |
} else { |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
121 |
lobbyLog.appendChat(playerName, s); |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
122 |
} |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
123 |
} |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
124 |
|
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
125 |
private MessageLog getCurrentLog() { |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
126 |
if(FLIB.flib_netconn_is_in_room_context(conn)) { |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
127 |
return roomLog; |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
128 |
} else { |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
129 |
return lobbyLog; |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
130 |
} |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
131 |
} |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
132 |
|
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
133 |
public void sendNick(String nick) { FLIB.flib_netconn_send_nick(conn, nick); } |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
134 |
public void sendPassword(String password) { FLIB.flib_netconn_send_password(conn, password); } |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
135 |
public void sendQuit(String message) { FLIB.flib_netconn_send_quit(conn, message); } |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
136 |
|
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
137 |
public boolean isConnected() { |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
138 |
return conn != null; |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
139 |
} |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
140 |
|
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
141 |
@Override |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
142 |
protected void finalize() throws Throwable { |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
143 |
if(conn != null) { |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
144 |
FLIB.flib_netconn_destroy(conn); |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
145 |
Log.e("Netconn", "Leaked Netconn object"); |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
146 |
} |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
147 |
} |
3f2e130f9715
Hedgeroid: Chat and player list work now, but everything is very much WIP
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
148 |
} |