summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--same-android/src/main/java/com/orbekk/GameView.java24
-rw-r--r--same-android/src/main/java/com/orbekk/HelloAndroidActivity.java3
2 files changed, 13 insertions, 14 deletions
diff --git a/same-android/src/main/java/com/orbekk/GameView.java b/same-android/src/main/java/com/orbekk/GameView.java
index edb41cb..1240671 100644
--- a/same-android/src/main/java/com/orbekk/GameView.java
+++ b/same-android/src/main/java/com/orbekk/GameView.java
@@ -6,6 +6,8 @@ import org.slf4j.LoggerFactory;
import com.orbekk.same.State.Component;
import com.orbekk.same.ClientService;
import com.orbekk.same.ClientServiceImpl;
+import com.orbekk.same.SameInterface;
+import com.orbekk.same.UpdateConflict;
import android.content.Context;
import android.graphics.Canvas;
@@ -28,13 +30,13 @@ public class GameView extends SurfaceView implements SurfaceHolder.Callback {
private Context context;
private Paint background;
private Paint paint;
- private ClientServiceImpl client;
+ private SameInterface same;
public GameThread(SurfaceHolder holder, Context context,
- ClientServiceImpl client) {
+ SameInterface client) {
this.holder = holder;
this.context = context;
- this.client = client;
+ this.same = client;
posX = 100;
posY = 100;
paint = new Paint();
@@ -72,20 +74,16 @@ public class GameView extends SurfaceView implements SurfaceHolder.Callback {
posX = x;
posY = y;
run();
- long rev = 0;
- Component c = client.getState("position");
- if (c != null) {
- rev = c.getRevision();
- }
-
- if (client.sendStateUpdate("position", this.posX + "," + this.posY,
- rev + 1)) {
- logger.warn("Unable to set state.");
+ try {
+ same.set("position", this.posX + "," + this.posY);
+ } catch (UpdateConflict e) {
+ logger.warn("Update conflict.", e);
}
+
}
}
- public GameView(Context context, ClientServiceImpl client) {
+ public GameView(Context context, SameInterface client) {
super(context);
getHolder().addCallback(this);
thread = new GameThread(getHolder(), context, client);
diff --git a/same-android/src/main/java/com/orbekk/HelloAndroidActivity.java b/same-android/src/main/java/com/orbekk/HelloAndroidActivity.java
index 9df93d9..87c349c 100644
--- a/same-android/src/main/java/com/orbekk/HelloAndroidActivity.java
+++ b/same-android/src/main/java/com/orbekk/HelloAndroidActivity.java
@@ -3,6 +3,7 @@ package com.orbekk;
import com.orbekk.net.Broadcaster;
import com.orbekk.same.ClientApp;
import com.orbekk.same.ClientServiceImpl;
+import com.orbekk.same.SameInterface;
import android.app.Activity;
import android.os.Bundle;
@@ -28,7 +29,7 @@ public class HelloAndroidActivity extends Activity {
Log.i(TAG, "onCreate");
// setContentView(R.layout.main);
ClientApp client = new ClientApp();
- ClientServiceImpl client_ = client.getClient(10015, "ClientNetwork",
+ SameInterface client_ = client.getClient(10015, "ClientNetwork",
"http://10.0.0.6:10010/");
setContentView(new GameView(this, client_));