Enable WebSocket communication through the October's AJAX framework-like API and build real-time applications.
Start the WebSocket server by:
php artisan websockets:run
You can specify a --port
if you want to, default is 8080.
Then add the client component on your page/layout. You can set an uri
property if you are running on a different port. Default is ws://localhost:8080/
.
[websocket]
It uses an AJAX framework-like API, is familiar for OctoberCMS developers
data-websocket-event="name"
It fires up send()
method with the specified event name.
data-websocket-oneventname="console.log(event)"
It evals the informed script, just like AJAX framework with a data argument.
You are ready to rock on sockets. Build a chat app!
Don't forget to add jQuery and {% scripts %}
placeholder.
url = "websockets" [websocket] == <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Web Sockets</title> </head> <body> <ul data-websocket-onmessage="$(this).append('<li>'+event.payload.text+'</li>')"></ul> <form role="form" data-websocket-event="message"> <input type="text" name="text"> <button type="submit">Send</button> </form> <script src="//code.jquery.com/jquery-1.12.0.min.js"></script> {% scripts %} </body> </html>
-
Wahyu Adi putra
Found the plugin not useful on 1 Jun, 2020
I have followed the documentation
failed: WebSocket opening handshake timed out
-
0.2.1 |
Update to new handle API method Mar 09, 2018 |
---|---|
0.2.0 |
Updated how dependencies are required Jul 12, 2016 |
0.1.0 |
API changes Feb 24, 2016 |
0.0.1 |
Work in Progress Feb 21, 2016 |