projects
/
brisk.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge remote-tracking branch 'origin/master' into nginx
[brisk.git]
/
web
/
xynt-streaming.js
diff --git
a/web/xynt-streaming.js
b/web/xynt-streaming.js
index
f80e8e8
..
47059a4
100644
(file)
--- a/
web/xynt-streaming.js
+++ b/
web/xynt-streaming.js
@@
-5,6
+5,16
@@
//
function transport_ws(doc, xynt_streaming, page)
{
//
function transport_ws(doc, xynt_streaming, page)
{
+ // if four arguments manage if WS or WSS connection
+ if (arguments.length > 3)
+ this.is_secure = arguments[3];
+ else
+ this.is_secure = false;
+
+ if (this.is_secure)
+ this.name = "WebSocketSecure";
+ else
+ this.name = "WebSocket";
this.ctx_new = "";
var self = this;
this.ctx_new = "";
var self = this;
@@
-12,12
+22,14
@@
function transport_ws(doc, xynt_streaming, page)
this.failed = false;
this.xynt_streaming = xynt_streaming;
try {
this.failed = false;
this.xynt_streaming = xynt_streaming;
try {
+ this.xynt_streaming.log("PAGE: "+page);
this.ws = new WebSocket(page);
this.ws.onopen = function () {
self.xynt_streaming.log("onopen");
if (this.readyState == 1) {
// connected
self.ws_cb("open");
this.ws = new WebSocket(page);
this.ws.onopen = function () {
self.xynt_streaming.log("onopen");
if (this.readyState == 1) {
// connected
self.ws_cb("open");
+ self.init_steps = 1;
}
};
this.ws.onmessage = function (msg) {
}
};
this.ws.onmessage = function (msg) {
@@
-26,11
+38,20
@@
function transport_ws(doc, xynt_streaming, page)
self.ctx_new += msg.data;
};
this.ws.onclose = function (msg) {
self.ctx_new += msg.data;
};
this.ws.onclose = function (msg) {
- self.xynt_streaming.log("onclose");
- self.ws_cb("close");
+ this.onopen = null;
+ this.onclose = null;
+ this.onerror = null;
+ self.xynt_streaming.log("onclose"+self.init_steps);
+ if (self.init_steps == 0)
+ self.ws_cb("error");
+ else
+ self.ws_cb("close");
};
this.ws.onerror = function () {
// on error
};
this.ws.onerror = function () {
// on error
+ this.onopen = null;
+ this.onclose = null;
+ this.onerror = null;
self.xynt_streaming.log("onerror");
self.ws_cb("error");
};
self.xynt_streaming.log("onerror");
self.ws_cb("error");
};
@@
-44,11
+65,14
@@
function transport_ws(doc, xynt_streaming, page)
transport_ws.prototype = {
doc: null,
transport_ws.prototype = {
doc: null,
+ name: null,
xynt_streaming: "ready",
ws: null,
stopped: true,
failed: false,
xynt_streaming: "ready",
ws: null,
stopped: true,
failed: false,
+ init_steps: 0,
+
ctx_old: "",
ctx_old_len: 0,
ctx_new: "",
ctx_old: "",
ctx_old_len: 0,
ctx_new: "",
@@
-68,6
+92,7
@@
transport_ws.prototype = {
if (from == "error") {
if (this.xynt_streaming != "ready") {
if (this.xynt_streaming.transp_fback > 0) {
if (from == "error") {
if (this.xynt_streaming != "ready") {
if (this.xynt_streaming.transp_fback > 0) {
+this.xynt_streaming.log("DEC: "+this.xynt_streaming.transp_fback);
this.xynt_streaming.transp_fback--;
this.stopped = true;
this.xynt_streaming.reload();
this.xynt_streaming.transp_fback--;
this.stopped = true;
this.xynt_streaming.reload();
@@
-81,6
+106,7
@@
transport_ws.prototype = {
ws_abort: function() {
if (this.ws != null) {
ws_abort: function() {
if (this.ws != null) {
+this.xynt_streaming.log("WSCLOSE");
this.ws.close();
}
},
this.ws.close();
}
},
@@
-146,6
+172,7
@@
transport_ws.prototype = {
//
function transport_xhr(doc, xynt_streaming, page)
{
//
function transport_xhr(doc, xynt_streaming, page)
{
+ this.name = "XHR";
this.doc = doc;
this.xynt_streaming = xynt_streaming;
this.xhr = createXMLHttpRequest();
this.doc = doc;
this.xynt_streaming = xynt_streaming;
this.xhr = createXMLHttpRequest();
@@
-160,6
+187,7
@@
function transport_xhr(doc, xynt_streaming, page)
transport_xhr.prototype = {
doc: null,
transport_xhr.prototype = {
doc: null,
+ name: null,
xynt_streaming: "ready",
xhr: null,
stopped: true,
xynt_streaming: "ready",
xhr: null,
stopped: true,
@@
-275,6
+303,7
@@
transport_xhr.prototype = {
//
function transport_htmlfile(doc, xynt_streaming, page)
{
//
function transport_htmlfile(doc, xynt_streaming, page)
{
+ this.name = "HTMLFile";
this.doc = doc;
this.xynt_streaming = xynt_streaming;
this.transfdoc = new ActiveXObject("htmlfile");
this.doc = doc;
this.xynt_streaming = xynt_streaming;
this.transfdoc = new ActiveXObject("htmlfile");
@@
-289,6
+318,7
@@
function transport_htmlfile(doc, xynt_streaming, page)
transport_htmlfile.prototype = {
doc: null,
transport_htmlfile.prototype = {
doc: null,
+ name: null,
xynt_streaming: null,
stopped: true,
ifra: null,
xynt_streaming: null,
stopped: true,
ifra: null,
@@
-378,6
+408,7
@@
transport_htmlfile.prototype = {
//
function transport_iframe(doc, xynt_streaming, page)
{
//
function transport_iframe(doc, xynt_streaming, page)
{
+ this.name = "IFRAME";
this.doc = doc;
this.xynt_streaming = xynt_streaming;
this.ifra = doc.createElement("iframe");
this.doc = doc;
this.xynt_streaming = xynt_streaming;
this.ifra = doc.createElement("iframe");
@@
-389,6
+420,7
@@
function transport_iframe(doc, xynt_streaming, page)
transport_iframe.prototype = {
doc: null,
transport_iframe.prototype = {
doc: null,
+ name: null,
xynt_streaming: null,
stopped: true,
ifra: null,
xynt_streaming: null,
stopped: true,
ifra: null,
@@
-599,24
+631,34
@@
xynt_streaming.prototype = {
// page arrangement
this.page = url_complete(this.win.location.href, this.page);
// page arrangement
this.page = url_complete(this.win.location.href, this.page);
+ // DEFAULT TRANSPORT PROTOCOL HERE websocketsec, websocket
if (this.transp_fback > 0) {
if (this.transp_fback > 0) {
- transp_type = "websocket";
- transp_port = (this.transp_fback == 2 ?
80
: 8080);
+ transp_type = "websocket
sec
";
+ transp_port = (this.transp_fback == 2 ?
443
: 8080);
}
else {
transp_type = this.transp_type;
transp_port = this.transp_port;
}
}
else {
transp_type = this.transp_type;
transp_port = this.transp_port;
}
- if (transp_type == "websocket") {
- var end_proto, first_slash;
+ if (transp_type == "websocket"
|| transp_type == "websocketsec"
) {
+ var end_proto, first_slash
, newpage
;
// change protocol
this.log("precha ["+this.page+"]");
// change protocol
this.log("precha ["+this.page+"]");
- end_proto = this.page.indexOf("://");
- first_slash = this.page.substring(end_proto+3).indexOf("/");
+ if (transp_type == "websocketsec") {
+ newpage = this.page.replace(/\.php$/g, "_wss.php").replace(/\.php\?/g, "_wss.php?");
+ }
+ else {
+ newpage = this.page;
+ }
+ end_proto = newpage.indexOf("://");
+ first_slash = newpage.substring(end_proto+3).indexOf("/");
- page = "ws://" + this.page.substring(end_proto+3, end_proto+3+first_slash) + ":" + transp_port + this.page.substring(end_proto+3 + first_slash);
+ page = (transp_type == "websocketsec" ? "wss://" : "ws://")
+ + newpage.substring(end_proto+3, end_proto+3 + first_slash) + ":"
+ + transp_port + newpage.substring(end_proto+3 + first_slash);
+ // this.log("MOP WS: " + page);
}
else {
page = this.page;
}
else {
page = this.page;
@@
-629,7
+671,11
@@
xynt_streaming.prototype = {
try {
// transport instantiation
try {
// transport instantiation
- if (transp_type == "websocket") {
+ if (transp_type == "websocketsec") {
+ page = url_append_args(page, "transp", "websocketsec");
+ this.transp = new transport_ws(this.doc, this, page, true);
+ }
+ else if (transp_type == "websocket") {
page = url_append_args(page, "transp", "websocket");
this.transp = new transport_ws(this.doc, this, page);
}
page = url_append_args(page, "transp", "websocket");
this.transp = new transport_ws(this.doc, this, page);
}
@@
-710,8
+756,7
@@
xynt_streaming.prototype = {
var ctx_new_len;
if (this.sandbox != null) {
var ctx_new_len;
if (this.sandbox != null) {
- // from old: var zug = "POLL sess = "+sess+" stat = "+stat+" subst = "+subst+" step = "+this.gst.st+" step_loc = "+this.gst.st_loc+" step_loc_new = "+this.gst.st_loc_new+" STOP: "+this.stopped;
- var zug = "WATCHDOG sess = ["+this.sess+"] step = "+this.gst.st+" step_loc = "+this.gst.st_loc+" step_loc_new = "+this.gst.st_loc_new;
+ var zug = "WATCHDOG sess = ["+this.sess+"] step = "+this.gst.st+" step_loc = "+this.gst.st_loc+" step_loc_new = "+this.gst.st_loc_new+"Transport: "+this.transp.name;
if (zug != this.sandbox.innerHTML)
this.sandbox.innerHTML = zug;
}
if (zug != this.sandbox.innerHTML)
this.sandbox.innerHTML = zug;
}
@@
-854,6
+899,7
@@
xynt_streaming.prototype = {
//xx this.hbit("+");
// alert("SINGLE: ["+singlecomm+"]");
//xx this.hbit("+");
// alert("SINGLE: ["+singlecomm+"]");
+ // window.console.log("["+singlecomm+"]");
this.cmdproc(singlecomm);
again = 1;
}
this.cmdproc(singlecomm);
again = 1;
}