Closed jmls closed 7 years ago
Hi @jmls, try publicly broadcasting the events from a bootscript as in https://github.com/mean-expert-official/fireloop.io/issues/57
ok, sure, I'll give that a bash - it's just the start function is running is after the system has booted, so not sure why that would make a difference
hmm
module.exports = function (app, cb) {
app.mx.IO.on("test1", function(msg) {
console.log("test1:", msg);
});
}
gives TypeError: Cannot read property 'IO' of undefined
I am trying to use just the IO part of loopback-component-realtime
, not fireloop.io as I have an existing strongloop app
app.on('started',() => {
app.mx.IO.on("test1", function(msg) {
console.log("===> test1:", msg);
});
app.mx.IO.emit("test1","foobar");
});
no message.
What I meant by "so not sure why that would make a difference" was that the orginal code I wrote was in the start function, after
the emit("started"), so it would behave exactly like the code in the bootscript. And it does - no message :(
yes I'm sorry I misunderstood, now I see in the original post you added the code within the start function within the server.js file and makes sense.
Mh ok, so what is strange is that you are not getting anything when calling the app.mx.IO.emit('test1') it should be fired...
Not sure if it would help but try updating the module to the latest RC, though not sure how much that would help, I mean the other 2 guys are successfully sending messages from the server side, though they are using the fireloop flavored version of loopback, there is no difference in terms of the real-time module, is the same.. so it should work the same
Look when you use the app.mx.IO.emit()
you are actually using the server instance emitting to everyone.
For everyone I mean all the clients, including the client instance, which in this case when you listen for app.mx.IO.on()
it actually is a client instance, not the server instance so it really should receive the message, as well as other clients.
At the end the app.mx.IO
object is just a facade of the IO Driver..
Closing for inactivity
so, I followed all the config options, and when I start the app, I get
the server code is
and the problem ? Well, I don't see
MESSAGE: hello world
Something stupid / simple that I missed ?