Permalink
Browse files

Added JSON parsing.

  • Loading branch information...
1 parent ca7b9df commit eb0d2dea5a0241adc98c0abf3b89f719eb227718 @ushadow committed May 25, 2012
Showing with 15 additions and 2 deletions.
  1. +1 −0 .classpath
  2. +2 −0 .gitignore
  3. 0 lib/.gitkeep
  4. +12 −2 src/mit/edu/yingyin/tabletop/apps/HandTrackingServerAppController.java
View
@@ -7,5 +7,6 @@
<classpathentry kind="lib" path="/usr/share/java/org.OpenNI.jar"/>
<classpathentry kind="lib" path="/socket_input/server/lib/servlet-api-3.0.jar"/>
<classpathentry kind="lib" path="/socket_input/server/lib/jetty-all-8.0.4.v20111024.jar"/>
+ <classpathentry kind="lib" path="lib/gson-2.2.1.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
View
@@ -1,2 +1,4 @@
bin/
.settings/
+lib/*
+!lib/.gitkeep
View
No changes.
@@ -1,11 +1,15 @@
package mit.edu.yingyin.tabletop.apps;
+import java.io.IOException;
import java.util.List;
import java.util.logging.Logger;
import org.OpenNI.GeneralException;
+import org.eclipse.jetty.util.ajax.JSON;
import org.eclipse.jetty.websocket.WebSocket.Connection;
+import com.google.gson.Gson;
+
import edu.mit.yingyin.tabletop.models.HandTracker.FingerEvent;
import edu.mit.yingyin.tabletop.models.HandTrackingEngine;
import edu.mit.yingyin.tabletop.models.HandTrackingEngine.IHandEventListener;
@@ -53,6 +57,7 @@ public void removeListener(IHandEventListener l) {
private HandTrackingThread handTrackingThread;
private Connection connection;
+ private Gson gson = new Gson();
public HandInputListener(HandTrackingThread handTrackingThread) {
this.handTrackingThread = handTrackingThread;
@@ -71,8 +76,12 @@ public void stopListening() {
@Override
public void fingerPressed(List<FingerEvent> feList) {
- // TODO Auto-generated method stub
-
+ String json = gson.toJson(feList);
+ try {
+ connection.sendMessage(json);
+ } catch (IOException e) {
+ logger.severe(e.getMessage());
+ }
}
}
@@ -93,6 +102,7 @@ public static void main(String... args) {
handTrackingThread.join();
} catch (Exception e) {
logger.severe(e.getMessage());
+ System.exit(-1);
}
}
}

0 comments on commit eb0d2de

Please sign in to comment.