I could make a php base 64 encoder for you to use with sha1, I have a website I can do that on.
there are default functions for this lol
so, i went with option d and made the following.
<?php
if($_GET["i"] !== "")
{
$_GET["i"] = $_GET["i"] . "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
$i = sha1($_GET["i"], true); // http://php.net/manual/en/function.sha1.php
$o = base64_encode($i);
echo $o;
}
?>// websockets code
if(!isObject(WebSocketClients))
new SimSet(WebSocketClients);
function Webclient::startWSResponse(%this)
{
%this.http = new httpObject()
{
classes = "WebSocketHttp";
isDone = false;
};
// %this.http.get("zombiesinthebluzone.co.cc:80", "/websocket.php?i=" @ $_SERVERHTTP_Sec_WebSocket_Key);
%this.http.get("localhost:80", "/websocket.php?i=" @ $_SERVERHTTP_Sec_WebSocket_Key);
%this.sched = %this.schedule(50, checkWSResponse);
}
function Webclient::finishWSResponse(%this)
{
%rkey = %this.http.stuff;
%this.http.stuff = "";
%this.send("HTTP/1.1 101 Switching Protocols\r\n");
%this.send("Upgrade: websocket\r\n");
%this.send("Connection: Upgrade\r\n");
%this.send("Sec-WebSocket-Accept: " @ %rkey @ "\r\n");
%this.send("\r\n");
%this.isWebSocket = 1;
WebSocketClients.add(%this);
}
function Webclient::checkWSResponse(%this)
{
cancel(%this.sched);
if(%this.http.isDone)
{
%this.finishWSResponse();
}
else
{
%this.sched = %this.schedule(150, checkWSResponse);
}
}
package webSockets
{
function httpObject::onLine(%this, %line)
{
parent::onLine(%this, %line);
if(%this.classes !$= "WebSocketHttp")
return;
%this.stuff = %this.stuff @ %line;
%this.isDone = true;
}
};
activatePackage("webSockets");some of the code is obviously formatted for local testing.
there was a major error where the system.. well, didn't work. however, in looking this over to post it might've found the error.
I edited the code with my final copy. It is fully functional, and the connections to the websocket is successful, no errors.
Websocket>server stuff will be handled via
Webclient::onLine with an
if() check to determine if
%this.isWebSocket.
server>websocket stuff will probably be handled by looping through the objects in the
WebSocketClients simset along with those little variables like methods. you know,
%this.isStuff = blah;.
thanks for all your help, guys!
only problem i'm seeing is a super-duper long response time when calculating the response key
i mean, yeah it'll take longer than local processing, but we're talking like 2-3 seconds here, and this is all happening locally!