Closed QRMarketing closed 9 years ago
Hello :-),
What did you do? Do you have Composer installed? Simply run:
$ composer require hoa/websocket
Then you include the vendor/autoload.php
file and you're ready to run all the examples.
Well first off it did not create composer it created composer.phar But this does not work either. I created a composer.json file, but ... the command just hangs. But frankly the instructions are a bit sketchy. I am sure there are good reasons for all this. You probably have everything setup nicely and assume everyone else does too. LoL. It would be nice to just download a file, say include and go. But life is never that easy is it. My guess is that when people see the install, they get scared and run.
But if you ever get it installed, the example code looks easy to use and interesting. I want to see if I can replace repetitive ajax queries. It is a shame, as it looks like good work, that I am sure that could be used more if people could get the car out of the parking lot.
Hello :-),
Composer is a pretty standard tool to install code. We rely on it because Hoa\Websocket
has some dependencies (to Hoa\Http
or Hoa\Stream
to name a few). Try with the following command-line:
$ composer.phar require hoa/websocket
You will have everything setup in a minute. To install Composer, check this page: https://getcomposer.org/doc/00-intro.md#downloading-the-composer-executable.
Yes this is the issue. You need access to the server to do all this stuff. Lots of Plesk errors and the hoster won't correct and even if you could get in, it would be a minefield of issues. I looked at standalone php servers, but none really work. Even the Php manual examples have commentators struggling with the bugs and errors. This is why websockets don't get used like Ajax. For the average programmer it is a challenge to get it set up and working.
First person that could really simplify this and correct the issues with good simple documentation and a hello world programme would be the winner. Nobody has done this yet.
Hey @QRMarketing ,
Have you gone through http://hoa-project.net/En/Literature/Hack/Websocket.html
There is also a video http://hoa-project.net/En/Awecode/Websocket.html which is not in English, but still useful to understand and follow.
I do have worked with, and I am not sure what you are really facing . May be you could please send a PR how to improve according to what you think.
Thank you
I realize that in fact being an average programmer you could easily say, learn more. I have already looked at your links. It makes me feel how can I use this. If I were building the library I would do something more simple like the following. The coder just downloads the server_hoa php file and the JS lib and goes. But perhaps this is wishful thinking. But this is what people are looking for. Unfortunately nothing exists like this. Very similar to what JQuery has done with Ajax.
my_server file:
<?php $host = "0.0.0.0"; $port = 9000; // perhaps other options include ("server_hoa.php"); // your cool library
on_connect($client_id) {
// mycode populate $server_buffer
send_message($server_buffer, $client_id);
};
on_disconnect($client_id) {
// mycode
};
on_message($buffer_client, $client_id) {
// mycode populate $server_buffer
send_message($server_buffer, $client_id);
send_broadcast($server_buffer); // or send broadcast to all client_id
};
?>
The client code you have is not to bad, but basically the same. Perhaps a Js include. But something like:
var host = "xxx"; var port = "xxx"; var client_id = "xxx"; var socket = create_socket(host, port, client_id);
socket.onclose = function (e) {
// mycode where I have client_id and the return server_buffer
return;
};
socket.onopen = function (e) { // mycode where I have client_id and the return server_buffer return; };
socket.onbroadcast = function (e) { // mycode where I have the return of the server_buffer return; };
socket.onmessage = function (e) { // mycode where I have client_id and the return server_buffer return; };
@QRMarketing Maybe you can run Composer locally, it will then grab all the dependencies for you, and then upload it on your server via FTP if the case you don't have any access. Thoughts?
@QRMarketing I consider this issue solved. If you still have an problem or if you consider it as unresolved, please feel free to reopen it or ask help!
I tried to follow all this composer stuff, but could get it to work. Not even sure this is what I want. Is there any easier way just to install the lib to get it to work. The install seems quite difficult. Any simple install help would be useful. Thanks.