mean-expert-official / loopback-component-realtime

The LoopBack Component that turns this great framework into a powerful real-time platform
MIT License
30 stars 17 forks source link

WebSocket data models on server side #26

Closed noroot closed 7 years ago

noroot commented 7 years ago

Do not understand how to use this component properly. Do I need to use special models or standard loopback model works fine with websocket data ? On client side everything seems good, data goes to loopback.io server

["Channel.messages.create.35084594729435", {"data":{"body":"test message","clientId":"589b78e500e682b07f5a6bcf","channelId":"58a77385c6760e832395f66a"},"parent":{"clientId":"589b78e500e682b07f5a6bcf","slug":"test","subject":"default","description":"default" ....

But nothing added to database, this dispatching event have no impact on server, basically nothing is happened except logging. My question is do I need to use special fireloop models, or I can use default loopback-sdk-builder generated models.

I generating models using this command:

./node_modules/.bin/lb-sdk server/server.js ../app/regular-app/src/shared/sdk/ -d ng2web -i enabled

Mixins are added to model-config

"../node_modules/@mean-expert/loopback-component-realtime/dist/mixins"

There is only one pub-sub mixin in folder, and looks like it is responsible to work with those socket received object, but nothing happend there.

Versions:

"@mean-expert/loopback-component-realtime": "^1.0.0-rc.2",
"@mean-expert/loopback-sdk-builder": "^2.1.0-rc.8",
"loopback": "^3.0.0",
jonathan-casarrubias commented 7 years ago

I'm assuming you are manually integrating FireLoop within LoopBack,

When using the fireloop-cli none of these configurations needs to be done, anyway you are always free to manually install it in a vanilla LoopBack project

If that is the case, then make sure also the component-config.json is updated as follows

{
  "loopback-component-explorer": {
    "mountPath": "/explorer"
  },
  "@mean-expert/loopback-component-realtime": {
    "auth": true, 
    "debug": false
  }
}  

auth and debug can be either true or false according your needs

Also you can try this repo, https://github.com/mean-expert-official/fireloop-todo-example that is an already working example.

To answer your question, you can use Standard Models, the same models you use with regular loopback services using the sdk builder, are the same that can be used with FireLoop.

You need to understand that fireloop does not change the core of LoopBack, but it provides a real-time gateway for clients to communicate with the backend.

Basically FireLoop is a different way to communicate with LoopBack than the LoopBack Rest Component, but at the end it remains being loopback.

I hope this clarify your questions, also I hope you are able to test the working example.

Cheers Jon

noroot commented 7 years ago

Solved. Everything works fine. It was double socket-io initialisation, from scratch it works as described.

jonathan-casarrubias commented 7 years ago

Amazing I'm glad you made it work

Cheers! Jon