Skip to content
Browse files

fix bug due to jsio std.URI api change; fix bug due to jsio lib.Enum …

…behavior change
  • Loading branch information...
1 parent 6a8298f commit 8723d8d5478d3f0e1a69f7c9fde2eb399c27149e @mcarter mcarter committed Jan 17, 2011
Showing with 720 additions and 24 deletions.
  1. +16 −6 daemon/orbited2/js_src/Orbited2.js
  2. +703 −17 daemon/orbited2/static/Orbited2.js
  3. +1 −1 tests/browser/tcp_socket.html
View
22 daemon/orbited2/js_src/Orbited2.js
@@ -1,17 +1,19 @@
jsio('from net.protocols.buffered import BufferedProtocol')
jsio('import net');
-jsio('import std.uri');
+jsio('import std.uri as Uri');
jsio('import std.JSON');
jsio('import std.utf8 as utf8');
jsio('import lib.Enum as Enum');
exports.logging = logging;
exports.logger = logger;
+//logger.setLevel(0)
+
var originalWebSocket = window.WebSocket;
-var baseUri = new std.uri.Uri(window.location);
+var baseUri = new Uri(window.location);
var defaultOrbitedUri;
@@ -23,7 +25,7 @@ function setup() {
for (var i = 0, script; script = scripts[i]; ++i) {
var src = script.src;
if (re.test(src)) {
- var uri = new std.uri.Uri(src.substring(0, src.length - target.length));
+ var uri = new Uri(src.substring(0, src.length - target.length));
defaultOrbitedUri = ((uri.getProtocol() || baseUri.getProtocol())
+ "://"
+ (uri.getHost() || baseUri.getHost()) + ":"
@@ -171,7 +173,7 @@ exports.WebSocket = Class(function() {
}
var _onOpen = function() {
- var uri = new std.uri.Uri(this.URL);
+ var uri = new Uri(this.URL);
this._conn.send(JSON.stringify({
hostname: uri.getHost(),
port: parseInt(uri.getPort()) || (uri.getProtocol() == 'ws' ? 80 : 443),
@@ -287,7 +289,7 @@ function getMultiplexer(baseUri, forceTransport) {
logger.debug('_transport is', _transport);
switch(_transport) {
case 'ws':
- var uri = new std.uri.Uri(baseUri);
+ var uri = new Uri(baseUri);
uri.setProtocol('ws');
var url = uri.render() + 'ws';
logger.debug('connecting with ws')
@@ -316,7 +318,11 @@ function releaseMultiplexer() {
}
}
-var FRAME = Enum('OPEN', 'CLOSE', 'DATA');
+var FRAME = Enum({
+ 'OPEN': 0,
+ 'CLOSE': 1,
+ 'DATA': 2
+});
DELIMITER = ',';
var Connection = Class(function() {
@@ -371,6 +377,9 @@ var OrbitedMultiplexingProtocol = Class(BufferedProtocol, function(supr) {
}
}
this._sendOpen = function(id) {
+ logger.debug('_sendOpen', id, FRAME.OPEN);
+ KKK = FRAME;
+ JJJ = FRAME.OPEN;
this.sendFrame(id, FRAME.OPEN);
}
this._sendClose = function(id) {
@@ -384,6 +393,7 @@ var OrbitedMultiplexingProtocol = Class(BufferedProtocol, function(supr) {
}
var idPayload = id + DELIMITER + type + DELIMITER + payload;
var frame = idPayload.length + DELIMITER + idPayload;
+ logger.debug('frame:', frame, 'id:', id, 'type:', type, 'payload:', payload);
this.transport.write(frame);
}
View
720 daemon/orbited2/static/Orbited2.js
703 additions, 17 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
2 tests/browser/tcp_socket.html
@@ -11,7 +11,7 @@
jsio('import .Orbited2_raw as Orbited2');
var sock = null;
function connect() {
- sock = new Orbited2.TCPSocket({ orbitedUri: "http://127.0.0.1:8000"});
+ sock = new Orbited2.TCPSocket({ orbitedUri: "http://127.0.0.1:8000", forceTransport: "csp"});
sock.open('127.0.0.1', 8014);
sock.onopen = function() {
console.log('TCPSocket onopen');

0 comments on commit 8723d8d

Please sign in to comment.
Something went wrong with that request. Please try again.