Rocket.Chat.js.SDK icon indicating copy to clipboard operation
Rocket.Chat.js.SDK copied to clipboard

Investigate approach to porting or modifying for use in front-end JS apps

Open filipef101 opened this issue 6 years ago • 12 comments

Hello, Do any of you know where I would start to port this to non node JS, as I wanted to use this in a react react native app but doesnt seem to be supported, any idea? Thanks

filipef101 avatar Jun 28 '18 11:06 filipef101

@filipef101 There was a user working on something like that, @abhi_hk95 on open.rocket.chat. I think it would be ideal if this package could be adapted to work on the client side as well, in react apps etc. I think the issue is certain node utilities in use are only available on the server. I'd like to understand it better and would be happy for anyone who did to provide a description of how it might be ported or why it can't be.

timkinnane avatar Jun 28 '18 11:06 timkinnane

@timkinnane this package basically uses https://github.com/RocketChat/asteroid from what I see, which by itselft seems to use packages that are not compatible with react for example, like faye-websocket, again I don't know much. Maybe its not possible due to dependencies :/

filipef101 avatar Jun 28 '18 12:06 filipef101

@abhishek71994

filipef101 avatar Jun 28 '18 12:06 filipef101

@filipef101 have a look at the work on #4 - there's some effort already to replace asteroid with a custom DDP client, I think using https://www.npmjs.com/package/ws - though I don't know if that presents the same problem for react?

timkinnane avatar Jun 28 '18 13:06 timkinnane

ping @JoseRenan

timkinnane avatar Jun 28 '18 13:06 timkinnane

faye-websocket is just one nodjs implementation of websocket, websocket is built into all modern browsers - that shouldn't be too much of a hurdle. This may be a start (although old and dormant): https://www.npmjs.com/package/asteroid.browser fwiw

Sing-Li avatar Jun 29 '18 11:06 Sing-Li

The WebSocket implementation used on Rocket Chat's react native client is the one that is built into the browsers. Searching now, the one which is used on #13 (https://www.npmjs.com/package/ws) is not compatible with browsers (I think it's the only library used that is not compatible with browsers after removing asteroid). I guess the same code (without the dependency) works on browsers because the DDP implementation in #13 is basically the same on Rocket Chat's react native client but written in TypeScript, I think it makes easier to support front-end apps :thinking:

JoseRenan avatar Jul 01 '18 19:07 JoseRenan

@JoseRenan Not sure if I'm following you. what would be the best aproach for this? a whole diferent package? Also I just stumbled upon this minutes ago. https://github.com/mongrov/roverz seems to be a client library for react native. possibly react too

filipef101 avatar Jul 01 '18 22:07 filipef101

In the last days i've been trying to port the code on https://github.com/RocketChat/Rocket.Chat.ReactNative to our app but haven't finished yet and still not sure if with success

filipef101 avatar Jul 01 '18 22:07 filipef101

This library choose between the nodejs WebSocket and the browser's one (and is recommended on https://www.npmjs.com/package/ws), I think it solves the portability problem in #13 with the migration from asteroid. What do you think, @timkinnane?

JoseRenan avatar Jul 02 '18 00:07 JoseRenan

@JoseRenan I'm not concerned which package is used under-the-hood to achieve in-browser support as long as the original tests pass and new test/s are added to ensure new client functionality gets the same results. It would preferably be still maintained and in popular use. isomorphic-ws doesn't look too good on that front, but I don't know what the alternatives are.

Something like mocha phantomjs could be used for new tests. I'm not too familiar with headless browser testing, so maybe there's better tools, but I like the consistency of keeping mocha to run tests for both node and front-end apps.

timkinnane avatar Jul 02 '18 03:07 timkinnane

Have you guys seen this DDP option? https://github.com/Gregivy/simpleddp

Forum discussion here: https://forums.meteor.com/t/new-js-ddp-client-simpleddp/46488/28

juliomac avatar Feb 26 '19 19:02 juliomac