I have all of my code on github, so I can edit my code on the fly, and simply do a git pull from the Pi and have my code updated. Right now, I'm trying to make a websocket between my Pi server and my client.
This is my Server.php
:
require_once 'WebSockets.php';
class Server extends WebSocketServer {
protected function process ($user, $message) {
$this->send($user,$message);
}
protected function connected ($user) { }
protected function closed ($user) { }
}
$server = new Server("localhost", "1738");
try {
$server->run();
}
catch (Exception $e) {
$server->stdout($e->getMessage());
}
and this is my client JS file:
(function() {
var URL = "ws://192.168.167.28:1738";
var ws = new WebSocket(URL);
ws.onopen = function(e) {
document.getElementById('serverStatus').innerHTML = "Connected";
document.getElementById('serverStatus').style.color = "green";
};
ws.onmessage = function(e) {
};
ws.onclose = function(e) {
document.getElementById('serverStatus').innerHTML = "Not Connected";
document.getElementById('serverStatus').style.color = "red";
};
});
What I think might be the problem is the way that I have my www/
directory set up. Currently, it is
www/ Pi-Room/ src/ php/Server.php
and I run Server.php from the command line. Do I need to change the address in my JS to reflect this file structure, or can I try slapping on a .htaccess
file which would redirect the user?