I am implementing socket.io with redis and nodejs. I have done with event and data is coming to the node server, but i am not receiving that data on my laravel 5 blade page.
Efforts
**blade page for receiving**
<script>
var socket = io('http://localhost:3000');
socket.on("test-channel:App\\Events\\MyEvent", function(message){
// increase the power everytime we load test route
console.log(message.data);
});
</script>
Above code which is running on client side and not displaying data.
socket.js file
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);
var Redis = require('redis');
var redis = Redis.createClient();
redis.subscribe('test-channel', function(err, count) {
// console.log(err,count);
});
redis.on('message', function(channel, message) {
console.log('Message Recieved: ' + message);
message = JSON.parse(message);
io.emit(channel + ':' + message.event, message.data);
});
http.listen(3000, function(){
console.log('Listening on Port 3000');
});
Above code which is running on server side and displaying data in terminal.
I don't understand where i am doing wrong. Please friend help me.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire