|
@@ -13,25 +13,34 @@ namespace TUIO
|
|
|
{
|
|
|
const int MAX_PACKET_SIZE = 65535 - 8;
|
|
|
|
|
|
- OSCTransmitter transmitter = null;
|
|
|
- String host = "127.0.0.1";
|
|
|
- int port = 3333;
|
|
|
+ private OSCTransmitter transmitter = null;
|
|
|
+ private String host = "127.0.0.1";
|
|
|
+ private int port = 3333;
|
|
|
+ private long sessionID = 0;
|
|
|
+ private TuioTime currentFrameTime;
|
|
|
|
|
|
- List<TuioCursor> cursorList = new List<TuioCursor>();
|
|
|
- List<TuioCursor> updatedCursorList;
|
|
|
+ private List<TuioCursor> cursorList;
|
|
|
+ private List<TuioCursor> updatedCursorList;
|
|
|
|
|
|
- public TuioServer() { transmitter = new OSCTransmitter(host, port); }
|
|
|
+ public TuioServer() { init(); }
|
|
|
|
|
|
public TuioServer(int port)
|
|
|
{
|
|
|
this.port = port;
|
|
|
- transmitter = new OSCTransmitter(host, port);
|
|
|
+ init();
|
|
|
}
|
|
|
|
|
|
public TuioServer(String host, int port)
|
|
|
{
|
|
|
this.host = host;
|
|
|
this.port = port;
|
|
|
+ init();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void init()
|
|
|
+ {
|
|
|
+ TuioTime.initSession();
|
|
|
+ cursorList = new List<TuioCursor>();
|
|
|
transmitter = new OSCTransmitter(host, port);
|
|
|
}
|
|
|
|
|
@@ -43,19 +52,35 @@ namespace TUIO
|
|
|
|
|
|
public TuioCursor addTuioCursor(float x, float y)
|
|
|
{
|
|
|
- TuioCursor tcur = new TuioCursor(cursorList.Count, cursorList.Count, x, y);
|
|
|
+ TuioCursor tcur = new TuioCursor(sessionID, cursorList.Count, x, y);
|
|
|
cursorList.Add(tcur);
|
|
|
updatedCursorList.Add(tcur);
|
|
|
+
|
|
|
+ sessionID++;
|
|
|
return tcur;
|
|
|
}
|
|
|
|
|
|
public void updateTuioCursor(TuioCursor tcur, float xp, float yp)
|
|
|
{
|
|
|
- tcur.update(new TuioTime(0, 0), xp, yp);
|
|
|
+ tcur.update(currentFrameTime, xp, yp);
|
|
|
if (!updatedCursorList.Contains(tcur))
|
|
|
updatedCursorList.Add(tcur);
|
|
|
}
|
|
|
|
|
|
+ public void updateTuioCursor(long s_id, float xp, float yp)
|
|
|
+ {
|
|
|
+ TuioCursor tcur;
|
|
|
+ for (int i = 0; i < cursorList.Count; i++)
|
|
|
+ {
|
|
|
+ tcur = cursorList[i];
|
|
|
+ if (tcur.getSessionID() == s_id)
|
|
|
+ {
|
|
|
+ updateTuioCursor(tcur, xp, yp);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public void removeTuioCursor(TuioCursor tcur)
|
|
|
{
|
|
|
cursorList.Remove(tcur);
|
|
@@ -64,6 +89,7 @@ namespace TUIO
|
|
|
|
|
|
public void initFrame()
|
|
|
{
|
|
|
+ currentFrameTime = TuioTime.getSessionTime();
|
|
|
updatedCursorList = new List<TuioCursor>();
|
|
|
}
|
|
|
|
|
@@ -91,7 +117,7 @@ namespace TUIO
|
|
|
currentMessage.Append("set");
|
|
|
currentMessage.Append((int)cursor.getSessionID());
|
|
|
currentMessage.Append((float)cursor.getX());
|
|
|
- currentMessage.Append((float)cursor.getY());
|
|
|
+ currentMessage.Append((float)cursor.getY());
|
|
|
currentMessage.Append((float)cursor.getXSpeed());
|
|
|
currentMessage.Append((float)cursor.getYSpeed());
|
|
|
currentMessage.Append((float)cursor.getMotionAccel());
|