-
Notifications
You must be signed in to change notification settings - Fork 75

Description
Let's say I have an simple post route and at the end of the post route I want to notify all of my connected brain socket clients that something has been added to the database.
I've tried
Route::post('/post', function() {
// Do db stuff here
// Notify all connected brainsocket clients
BrainSocket::message('postAdded', array('message'=>'a post has been added'));
Redirect::to('/posts');
});
But my connected clients don't get the messages.
My web clients have the following
window.app = {};
app.BrainSocket = new BrainSocket(
new WebSocket('ws://localhost:8080'),
new BrainSocketPubSub()
);
// Brain Socket Events to listen for
app.BrainSocket.Event.listen('postAdded',function(msg){
console.log(msg);
});
It doesn't seem like executing BrainSocket::message anywhere outside of the laravel events.php file will push messages to my clients.
I've also tried having a generic event in my events.php file called add post which would fire when forced, ie
$event = Event::fire('addcall', array('msg'=>'help'));
Event::listen('addpost', function($client_data){
Log::info('running add post event');
return BrainSocket::message('callAddedToQueue', array('message'=>'Call Added'));
});
The event fires(I know because it's logged in the lararvel.log file) but the message is never broadcast out to client.s
Am I just doing it wrong? Does brainsocket not support push messages or the functionality I'm trying to achieve?
Any help would be appreciated!