1. Martin Thorsen Ranang
  2. orbited

Commits

ma...@fe34127c-c842-0410-aa83-9fc675b9a81c  committed d7a0d73

initial work with jsio

  • Participants
  • Parent commits 2eefe68
  • Branches 0.8

Comments (0)

Files changed (1)

File daemon/orbited/jsiotest.html

View file
+<html>
+ <head>
+  <script src="jsio/jsio.js"></script>
+  <script>
+    onload = function() {
+        jsio('import Class');
+        jsio('from jsio.protocols.mspp import MSPPStream, MSPPProtocol');
+
+        Orbited = {};
+        Orbited.settings = {};
+        Orbited.settings.host = "localhost";
+        Orbited.settings.port = 8000;
+        Orbited.multiplexer = null;
+
+        Orbited.TCPSocket = Class(MSPPStream, function() {
+            this.init = function() {
+                this.setEncoding('plain');
+                if (Orbited.multiplexer == null) {
+                    Orbited.multiplexer = new MSPPProtocol();
+                    Orbited.multiplexer.setTransport('csp', {"url": "http://" + Orbited.settings.host + ":" + Orbited.settings.port + "/csp"});
+                }
+                this.setMultiplexer(Orbited.multiplexer);
+            }
+        });
+
+        socket = new Orbited.TCPSocket();
+        socket.onopen = function() { console.log('connected'); }
+        socket.onclose = function(err) { console.log('close: '+err); }
+        socket.onread = function(data) { console.log('read: '+data); }
+        socket.open('localhost', 8888);
+    };
+  </script>
+ </head>
+ <body></body>
+</html>