1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

fix-script-to-synthesize-websocket-url-entirely-from-script-url.patch

Signed-off-by: Andy Green <andy@warmcat.com>
This commit is contained in:
Andy Green 2010-11-15 19:39:30 +00:00
parent 5ba6bb7cf5
commit 24cc0aea16
2 changed files with 22 additions and 8 deletions

View file

@ -1,6 +1,6 @@
Name: libwebsockets
Version: 0.1
Release: 15.gmaster_8003f024%{?dist}
Release: 17.gmaster_523a3971%{?dist}
Summary: Websocket Server Library
Group: System

View file

@ -49,22 +49,36 @@ protocol, including the guy who sent the packet.
<script>
var pos = 0;
function get_appropriate_ws_url(ads)
function get_appropriate_ws_url()
{
var pcol;
var u = document.URL;
/*
* We open the websocket encrypted if this page came on an
* https:// url itself, otherwise unencrypted
*/
if (document.URL.substring(0, 5) == "https")
return "wss://"+ads;
else
return "ws://"+ads;
if (u.substring(0, 5) == "https") {
pcol = "wss://";
u = u.substr(8);
} else {
pcol = "ws://";
if (u.substring(0, 4) == "http")
u = u.substr(7);
}
u = u.split('/');
return pcol + u[0];
}
document.getElementById("number").textContent = get_appropriate_ws_url();
/* dumb increment protocol */
var socket_di = new WebSocket(get_appropriate_ws_url("127.0.0.1:7681"),
var socket_di = new WebSocket(get_appropriate_ws_url(),
"dumb-increment-protocol");
try {
@ -96,7 +110,7 @@ function reset() {
var no_last = 1;
var last_x = 0, last_y = 0;
var ctx;
var socket_lm = new WebSocket(get_appropriate_ws_url("127.0.0.1:7681"),
var socket_lm = new WebSocket(get_appropriate_ws_url(),
"lws-mirror-protocol");
var color = "#000000";