~ubuntu-branches/ubuntu/oneiric/haxe/oneiric

« back to all changes in this revision

Viewing changes to haxe/std/js/XMLSocket.hx

  • Committer: Bazaar Package Importer
  • Author(s): Jens Peter Secher
  • Date: 2009-03-18 23:09:50 UTC
  • mfrom: (3.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20090318230950-pgfuxg2ucolps74t
Tags: 1:2.2-2
* Use ocamlfind to locate and use the libraries xml-light and extlib
  which already exist in Debian as separate packages.
  (Closes: #519630)
* Fixed compile error with camlp4 3.11, thanks to Stéphane Glondu.
  (Closes: #519627)
* Use quilt instead of dpatch for patches, and describe how to use
  quilt in Debian.source (thanks to Russ Allbery).
* Added a Vcs-Hg control filed to indicate the location of the public
  repository.
* Bumped Standards-Version to 3.8.1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
**/
30
30
class XMLSocket {
31
31
 
32
 
        static var sockets = Reflect.empty();
33
 
        static var ID = 0;
34
 
 
35
 
        var id : String;
36
 
        var rcnx : haxe.remoting.Connection;
37
 
        var cnx : haxe.remoting.Connection;
 
32
        var cnx : haxe.remoting.ExternalConnection;
38
33
 
39
34
        public function new( flashObject : String ) {
40
 
                id = "s"+(ID++);
41
 
                rcnx = haxe.remoting.Connection.flashConnect(flashObject).haxe.remoting.SocketWrapper;
42
 
                rcnx.create.call([id]);
43
 
                this.cnx = rcnx.sockets.__resolve(Std.string(id));
44
 
                Reflect.setField(sockets,id,this);
45
 
        }
46
 
 
47
 
        public function destroy() {
48
 
                rcnx.destroy.call([id]);
49
 
                Reflect.deleteField(sockets,id);
 
35
                var ctx = new haxe.remoting.Context();
 
36
                var cnx = haxe.remoting.ExternalConnection.flashConnect("SocketWrapper",flashObject,ctx);
 
37
                var sockId = cnx.api.create.call([flashObject]);
 
38
                cnx.close();
 
39
                ctx.addObject("api",this,false);
 
40
                this.cnx = haxe.remoting.ExternalConnection.flashConnect(sockId,flashObject,ctx);
50
41
        }
51
42
 
52
43
        public function connect( host : String, port : Int ) {
53
 
                cnx.connect.call([host,port]);
 
44
                cnx.sock.connect.call([host,port]);
54
45
        }
55
46
 
56
47
        public function send( data : String ) {
57
 
                cnx.send.call([data]);
 
48
                cnx.sock.send.call([data]);
58
49
        }
59
50
 
60
51
        public function close() {
61
 
                cnx.close.call([]);
62
 
        }
63
 
 
64
 
        public function onData( data : String ) {
65
 
        }
66
 
 
67
 
        public function onClose() {
68
 
        }
69
 
 
70
 
        public function onConnect( b : Bool ) {
 
52
                cnx.sock.close.call([]);
 
53
                cnx.api.destroy.call([]);
 
54
                cnx.close();
 
55
        }
 
56
 
 
57
        public dynamic function onData( data : String ) {
 
58
        }
 
59
 
 
60
        public dynamic function onClose() {
 
61
        }
 
62
 
 
63
        public dynamic function onConnect( b : Bool ) {
71
64
        }
72
65
 
73
66
}