/usr/share/doc/mongrel2-core/examples/chat/static/flash/jsSocket.as is in mongrel2-core 1.9.1-6+deb8u1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | import flash.external.ExternalInterface;
class jsSocket {
private var sock:XMLSocket;
private var id:String;
private function calljs(type, data) {
ExternalInterface.call('jsSocket.callback', this.id, type, data);
}
public function jsSocket(id) {
this.id = id;
ExternalInterface.addCallback('open', this, open);
ExternalInterface.addCallback('send', this, send);
ExternalInterface.addCallback('close', this, close);
this.calljs('onLoaded', true);
}
public function open(host, port) {
System.security.loadPolicyFile('xmlsocket://' + host + ':' + port);
sock = new XMLSocket();
var self = this;
sock.onConnect = function(s) { self.calljs('onOpen', s); }
sock.onData = function(d) { self.calljs('onData', d); }
sock.onClose = function( ) { self.calljs('onClose'); }
return sock.connect(host, port);
}
public function send(data) {
if (data != 'null') // calling send() from js with no arguments sets data == 'null'
return sock.send(data);
}
public function close() {
sock.close();
sock.onClose();
}
static function main(mc) {
_root.jsSocket = new jsSocket(_root.id);
}
}
|