project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/GameConnection.java
changeset 7558 983ff426f91e
parent 7508 763d3961400b
child 7582 714310efad8f
equal deleted inserted replaced
7556:4617e8ec0507 7558:983ff426f91e
     8 import org.hedgewars.hedgeroid.frontlib.Frontlib.GameconnPtr;
     8 import org.hedgewars.hedgeroid.frontlib.Frontlib.GameconnPtr;
     9 import org.hedgewars.hedgeroid.frontlib.Frontlib.IntCallback;
     9 import org.hedgewars.hedgeroid.frontlib.Frontlib.IntCallback;
    10 import org.hedgewars.hedgeroid.frontlib.Frontlib.StrBoolCallback;
    10 import org.hedgewars.hedgeroid.frontlib.Frontlib.StrBoolCallback;
    11 import org.hedgewars.hedgeroid.frontlib.Frontlib.StrCallback;
    11 import org.hedgewars.hedgeroid.frontlib.Frontlib.StrCallback;
    12 import org.hedgewars.hedgeroid.frontlib.Frontlib.VoidCallback;
    12 import org.hedgewars.hedgeroid.frontlib.Frontlib.VoidCallback;
       
    13 import org.hedgewars.hedgeroid.frontlib.NativeSizeT;
    13 import org.hedgewars.hedgeroid.netplay.GameMessageListener;
    14 import org.hedgewars.hedgeroid.netplay.GameMessageListener;
    14 import org.hedgewars.hedgeroid.netplay.Netplay;
    15 import org.hedgewars.hedgeroid.netplay.Netplay;
    15 import org.hedgewars.hedgeroid.util.TickHandler;
    16 import org.hedgewars.hedgeroid.util.TickHandler;
    16 
    17 
    17 import android.os.Handler;
    18 import android.os.Handler;
    18 import android.os.HandlerThread;
    19 import android.os.HandlerThread;
    19 import android.os.Looper;
    20 import android.os.Looper;
    20 import android.util.Log;
    21 import android.util.Log;
    21 
    22 
    22 import com.sun.jna.Memory;
    23 import com.sun.jna.Memory;
    23 import com.sun.jna.NativeLong;
       
    24 import com.sun.jna.Pointer;
    24 import com.sun.jna.Pointer;
    25 
    25 
    26 public final class GameConnection {
    26 public final class GameConnection {
    27 	private static final Handler mainHandler = new Handler(Looper.getMainLooper());
    27 	private static final Handler mainHandler = new Handler(Looper.getMainLooper());
    28 	
    28 	
   160 		}
   160 		}
   161 	};
   161 	};
   162 	
   162 	
   163 	// runs on the IPCThread
   163 	// runs on the IPCThread
   164 	private final BytesCallback engineMessageCb = new BytesCallback() {
   164 	private final BytesCallback engineMessageCb = new BytesCallback() {
   165 		public void callback(Pointer context, Pointer buffer, NativeLong size) {
   165 		public void callback(Pointer context, Pointer buffer, NativeSizeT size) {
   166 			netplay.sendEngineMessage(buffer.getByteArray(0, size.intValue()));
   166 			netplay.sendEngineMessage(buffer.getByteArray(0, size.intValue()));
   167 		}
   167 		}
   168 	};
   168 	};
   169 	
   169 	
   170 	// runs on the IPCThread
   170 	// runs on the IPCThread
   195 		public void onEngineMessage(final byte[] em) {
   195 		public void onEngineMessage(final byte[] em) {
   196 			handler.post(new Runnable() {
   196 			handler.post(new Runnable() {
   197 				public void run() {
   197 				public void run() {
   198 					Memory mem = new Memory(em.length);
   198 					Memory mem = new Memory(em.length);
   199 					mem.write(0, em, 0, em.length);
   199 					mem.write(0, em, 0, em.length);
   200 					Flib.INSTANCE.flib_gameconn_send_enginemsg(conn, mem, new NativeLong(em.length));
   200 					Flib.INSTANCE.flib_gameconn_send_enginemsg(conn, mem, NativeSizeT.valueOf(em.length));
   201 				}
   201 				}
   202 			});
   202 			});
   203 			
       
   204 		}
   203 		}
   205 		
   204 		
   206 		public void onChatMessage(final String nick, final String message) {
   205 		public void onChatMessage(final String nick, final String message) {
   207 			handler.post(new Runnable() {
   206 			handler.post(new Runnable() {
   208 				public void run() {
   207 				public void run() {