sidneywidmer / latchet Goto Github PK
View Code? Open in Web Editor NEWWebSockets with Laravel 4
WebSockets with Laravel 4
Hello, I have my website on shared hosting and can't connect to other port then 80, do I need to start server or can I still listen to socket connections?
Could this be added to packagist ?
^ title
Hey @sidneywidmer , thank for your wonderfull package before. I have some question, Push message is working on my first visit on browser.
The trigger publish event is called by RESTFULL
// Trigger to push notification on all client
Router::post('/postsomething', function(){
Latchet::publish('chat/room/12', array('msg' => 'foo'));
})
Here is my Connection code
<?php
namespace Hunter\Sockets;
use Sidney\Latchet\BaseConnection;
use Hunter\Core\User;
class Connection extends BaseConnection {
public function open($connection)
{
$connection->sockets = new \StdClass;
$connection->sockets->name = $connection->WAMP->sessionId;
}
public function close($connection)
{
$user = $connection->sockets->name;
echo "connection closed. User: " . $user . " \n";
$connection->close();
}
public function error($connection, $exception)
{
//close the connection
$connection->close();
echo $exception->getMessage();
throw new \Exception($exception);
}
}
ChatTopic
<?php
namespace Hunter\Sockets;
use Sidney\Latchet\BaseTopic;
class ChatTopic extends BaseTopic
{
public function subscribe($connection, $topic)
{
// $connection->sockets->currentRoom = $topic;
echo $topic."\n";
}
public function publish($connection, $topic, $message, array $exclude, array $elligible)
{
$this->broadcast($topic, array('msg' => $message ));
}
public function call($connection, $id, $topic, array $params)
{
}
public function unsubscribe($connection, $topic)
{
}
}
and the events
Latchet::connection('Hunter\Sockets\Connection');
Latchet::topic('chat/room/{roomid}', 'Hunter\Sockets\ChatTopic');
<!DOCTYPE html>
<html lang="en" ng-app="App">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
</head>
<body>
<!--[if lt IE 10]>
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
<![endif]-->
<div class="message-bar"></div>
<script src="http://autobahn.s3.amazonaws.com/js/autobahn.min.js"></script>
<script>
var socket;
ab.connect('ws://chunterapp.dev:8080',
function (session) {
// subscribe is not working after reload browser :(
session.subscribe('chat/room/12', function (topic, msg) {
console.log(topic);
});
},
function (code, reason, detail) {
session = null;
// alert(reason);
},
{
}
);
</script>
</body>
</html>
My code in the above is working on my first visit on the browser, but when i reload the browser push message on subscribe is not working, until i restart latchet listen.
Thanks for your help.
Current version could raise an exception Tried to write to closed stream
after socket connectition for many hours
I'm missing something here. I'm following along with your docs. When I run the start command "sudo php artisan latchet:listen" and I try to make a websocket connection to the server ('ws://localhost:1111') the instance shuts down and echos out
[UnexpectedValueException]
$request can not be null
I used artisan to generate the files and then went to test when I received this error.
I have successfully installed and configured everything for this package, just to reach the point that I learned that websocket protocol must be wss over https connections. how can I configure this package to behave as WSS entry point?
Any plans to make it compatible with Laravel 5?
Hi,
I have the next question - how is it possible to allow the connections to the channels only for the 1. authorized customers AND 2. only for certain customer.
E.g. I want to establish the private websocket connection with the customer with id 3 and I want to send the notifications through that channel.
Considering, that I want to be sure, that any other customer or hacker would not be able to connect to that channel. How this could be done with Latchet? Is there any concept to cover this?
Thanks
After some frustrating hours I found out that Autobahn|JS 0.9 is not supported by Ratchet. You have to use Version 0.8. Maybe you should add a note to the documentation.
I used Latchet in production for a half month. It's seems like not very stable for many(about 50%) messages can't get arrived at client from server.
I don't konw how to debug with the issue. It's result of zmq or latchet or ratchet? I don't konw.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.