front_idill/extern/fajran-tuiojs/connector/stomp/tuio.stomp.js
author bastiena
Fri, 06 Apr 2012 18:32:13 +0200
changeset 25 a7b0e40bcab0
permissions -rw-r--r--
Front IDILL : Basic JS TUIO lib loaded
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
25
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
     1
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
     2
tuio.setConnector({
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
     3
	_host: 'localhost',
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
     4
	_port: 61613,
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
     5
	_user: 'guest',
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
     6
	_pass: 'guest',
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
     7
	_topic: '/topic/home',
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
     8
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
     9
	_client: undefined,
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    10
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    11
	start: function() {
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    12
		var self = this;
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    13
		var sc = new STOMPClient();
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    14
		self._client = sc;
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    15
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    16
		sc.onopen = function() {
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    17
		}
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    18
		sc.onclose = function(code) {
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    19
		}
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    20
		sc.onerror = function(err) {
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    21
		}
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    22
		sc.onerrorframe = function(frame) {
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    23
		}
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    24
		sc.onconnectedframe = function() {
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    25
			sc.subscribe(self._topic, {exchange:''});
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    26
		}
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    27
		sc.onmessageframe = function(frame) {
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    28
			self._process(frame.body.split(" "));
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    29
		}
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    30
		setTimeout(function() {
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    31
			sc.connect(self._host, self._port, self._user, self._pass);
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    32
		}, 10);
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    33
	},
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    34
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    35
	stop: function() {
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    36
		this._client.reset();
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    37
	},
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    38
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    39
	_process: function(data) {
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    40
		var type = parseInt(data[0]);
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    41
		var sid = parseInt(data[1]);
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    42
		var fid = parseInt(data[2]);
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    43
		var x = parseFloat(data[3]);
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    44
		var y = parseFloat(data[4]);
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    45
		var angle = parseFloat(data[5]);
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    46
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    47
		tuio.callback(type, sid, fid, x, y, angle);
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    48
	}
a7b0e40bcab0 Front IDILL :
bastiena
parents:
diff changeset
    49
});