project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/netplay/ThreadedNetConnection.java
equal
deleted
inserted
replaced
36 import org.hedgewars.hedgeroid.frontlib.Frontlib.TeamCallback; |
36 import org.hedgewars.hedgeroid.frontlib.Frontlib.TeamCallback; |
37 import org.hedgewars.hedgeroid.frontlib.Frontlib.TeamPtr; |
37 import org.hedgewars.hedgeroid.frontlib.Frontlib.TeamPtr; |
38 import org.hedgewars.hedgeroid.frontlib.Frontlib.VoidCallback; |
38 import org.hedgewars.hedgeroid.frontlib.Frontlib.VoidCallback; |
39 import org.hedgewars.hedgeroid.frontlib.Frontlib.WeaponsetCallback; |
39 import org.hedgewars.hedgeroid.frontlib.Frontlib.WeaponsetCallback; |
40 import org.hedgewars.hedgeroid.frontlib.Frontlib.WeaponsetPtr; |
40 import org.hedgewars.hedgeroid.frontlib.Frontlib.WeaponsetPtr; |
|
41 import org.hedgewars.hedgeroid.frontlib.NativeSizeT; |
41 import org.hedgewars.hedgeroid.netplay.Netplay.FromNetHandler; |
42 import org.hedgewars.hedgeroid.netplay.Netplay.FromNetHandler; |
42 import org.hedgewars.hedgeroid.netplay.Netplay.FromNetMsgType; |
43 import org.hedgewars.hedgeroid.netplay.Netplay.FromNetMsgType; |
43 import org.hedgewars.hedgeroid.util.FileUtils; |
44 import org.hedgewars.hedgeroid.util.FileUtils; |
44 import org.hedgewars.hedgeroid.util.TickHandler; |
45 import org.hedgewars.hedgeroid.util.TickHandler; |
45 |
46 |
52 import android.os.Message; |
53 import android.os.Message; |
53 import android.util.Log; |
54 import android.util.Log; |
54 import android.util.Pair; |
55 import android.util.Pair; |
55 |
56 |
56 import com.sun.jna.Memory; |
57 import com.sun.jna.Memory; |
57 import com.sun.jna.NativeLong; |
|
58 import com.sun.jna.Pointer; |
58 import com.sun.jna.Pointer; |
59 |
59 |
60 /** |
60 /** |
61 * This class handles the actual communication with the networking library, running on a separate thread. |
61 * This class handles the actual communication with the networking library, running on a separate thread. |
62 * |
62 * |
310 sendFromNet(MSG_HOG_COUNT_CHANGED, hogCount, teamName); |
310 sendFromNet(MSG_HOG_COUNT_CHANGED, hogCount, teamName); |
311 } |
311 } |
312 }; |
312 }; |
313 |
313 |
314 private final BytesCallback engineMessageCb = new BytesCallback() { |
314 private final BytesCallback engineMessageCb = new BytesCallback() { |
315 public void callback(Pointer context, Pointer buffer, NativeLong size) { |
315 public void callback(Pointer context, Pointer buffer, NativeSizeT size) { |
316 sendFromNet(MSG_ENGINE_MESSAGE, buffer.getByteArray(0, size.intValue())); |
316 sendFromNet(MSG_ENGINE_MESSAGE, buffer.getByteArray(0, size.intValue())); |
317 } |
317 } |
318 }; |
318 }; |
319 |
319 |
320 private final VoidCallback runGameCb = new VoidCallback() { |
320 private final VoidCallback runGameCb = new VoidCallback() { |
496 } |
496 } |
497 case MSG_SEND_ENGINE_MESSAGE: { |
497 case MSG_SEND_ENGINE_MESSAGE: { |
498 byte[] message = (byte[])msg.obj; |
498 byte[] message = (byte[])msg.obj; |
499 Memory mem = new Memory(message.length); |
499 Memory mem = new Memory(message.length); |
500 mem.write(0, message, 0, message.length); |
500 mem.write(0, message, 0, message.length); |
501 FLIB.flib_netconn_send_engineMessage(conn, mem, new NativeLong(message.length)); |
501 FLIB.flib_netconn_send_engineMessage(conn, mem, NativeSizeT.valueOf(message.length)); |
502 break; |
502 break; |
503 } |
503 } |
504 case MSG_SEND_ROUND_FINISHED: { |
504 case MSG_SEND_ROUND_FINISHED: { |
505 FLIB.flib_netconn_send_roundfinished(conn, (Boolean)msg.obj); |
505 FLIB.flib_netconn_send_roundfinished(conn, (Boolean)msg.obj); |
506 break; |
506 break; |
543 } |
543 } |
544 case MSG_SEND_MAP_DRAWDATA: { |
544 case MSG_SEND_MAP_DRAWDATA: { |
545 byte[] message = (byte[])msg.obj; |
545 byte[] message = (byte[])msg.obj; |
546 Memory mem = new Memory(message.length); |
546 Memory mem = new Memory(message.length); |
547 mem.write(0, message, 0, message.length); |
547 mem.write(0, message, 0, message.length); |
548 FLIB.flib_netconn_send_mapDrawdata(conn, mem, new NativeLong(message.length)); |
548 FLIB.flib_netconn_send_mapDrawdata(conn, mem, NativeSizeT.valueOf(message.length)); |
549 break; |
549 break; |
550 } |
550 } |
551 case MSG_SEND_GAMESTYLE: { |
551 case MSG_SEND_GAMESTYLE: { |
552 FLIB.flib_netconn_send_script(conn, (String) msg.obj); |
552 FLIB.flib_netconn_send_script(conn, (String) msg.obj); |
553 break; |
553 break; |