Skip to content
This repository has been archived by the owner on Jun 7, 2020. It is now read-only.

Meteor DDP connection #35

Closed
rafaelks opened this issue Aug 31, 2015 · 27 comments
Closed

Meteor DDP connection #35

rafaelks opened this issue Aug 31, 2015 · 27 comments
Assignees

Comments

@rafaelks
Copy link
Contributor

The native app must connect with Meteor server via DDP protocol.

Here's a nice lib for iOS to make DDP connection: https://github.com/martijnwalraven/meteor-ios.

@rafaelks rafaelks self-assigned this Aug 31, 2015
@rafaelks rafaelks added this to the v0.1.0 milestone Aug 31, 2015
@rafaelks
Copy link
Contributor Author

@rodrigok Can you explain how the basic connection works?

Just to get started:

  1. Authentication
  2. List of Channels

@rafaelks
Copy link
Contributor Author

This one (https://github.com/boundsj/ObjectiveDDP) is actually more interesting, because it have authentication methods that follow Meteor pattern.

@felipeflorencio
Copy link
Contributor

Looks good, and quite a lot has been done, we just need look into library and maybe help improvement i saw that does not have to much commit last fill months, i already started looking into code, but i believe is a good start 👍

@gsaslis
Copy link
Contributor

gsaslis commented Sep 1, 2015

Yes I also had the one @rafaelks mentioned in mind... Haven't looked into either of them in much detail yet though..

Do you guys know why we should go with DDP and not use the REST APIs that Rocket.Chat provides?
I know virtually nothing about DDP but I guess we get the updates without having to poll the REST APIs, right?

@felipeflorencio
Copy link
Contributor

One great advantage from approach of using DDP its her use of websocket, while REST will lead to always create connection for request, we will actually open multiple channels some times for do our requests, and depend of how many messages user are sending and receiving, this could cause overhead, sure thinking at big scale.
Its basically whenever you made a request, say to download html, or an image, a port/socket was opened, data was transferred, and then it was closed.
With socket this is prevented, actually, using socket they create like one channel to request and get response. Unlike HTTP, the socket that is connected to the server stays “open” for communication. That means data can be “pushed” to the browser in realtime on demand.
While some think that this is bad for example because connection being open could lead to higher battery consumption, its wrong, actually using some "chat protocol" like web socket had advantages into this because not open, and close multiple times, and prevent system getting creating threads all the time.
At market had other types of "chat protocols", but socket its well know and a good one i believe and of course meteor handle with.

I really like REST, but for purpose of "chat", this interface i believe we need go with socket :)

I don't know if helped, any other information will be helpful :)

@Sing-Li
Copy link
Member

Sing-Li commented Sep 1, 2015

Hey, I'm the guy who did the REST API. And in my honest opinion - please don't use it ! 😁

Let me better qualify ... please don't use it for the Native iOS app.

Meteor and DDP are what defines Rocket.Chat, otherwise we're just another kindamatter, slacky dak, let's yap, etc. We're talking about two orders of magnitude difference in terms of responsiveness, scalability, and efficiency.

It is a royal pain to adapt existing UIKit views, especially for UITableView - but result will be worth it. Some bleeding edge attempts to adapt:

http://componentkit.org/

https://www.objc.io/issues/22-scale/facebook/

@gsaslis
Copy link
Contributor

gsaslis commented Sep 1, 2015

awesome! thanks so much for sharing this info @felipeflorencio / @Sing-Li !!

I guess we only need to decide on which ddp library to use then... Anyone have any thoughts to share on that?

@rafaelks
Copy link
Contributor Author

rafaelks commented Sep 1, 2015

Thanks @felipeflorencio, @Sing-Li! :-)

So, I was studying both libs yesterday and seems that https://github.com/boundsj/ObjectiveDDP is better to us. Or maybe we could create a new lib based on DDP specification (sounds too crazy?).

@rodrigok
Copy link
Member

rodrigok commented Sep 2, 2015

@rafaelks I liked your crazy idea :) all existing libs of DDP for iOS sucks, creating a new one using swift 2 would be better and likely a good experience, but you will need to port EJSON and MiniMongo too.

@felipeflorencio
Copy link
Contributor

Sounds good, i already saw a little about this lib ObjectiveDDP and need some improvements, if we started create a new one with just what we want. Would be great start new one :)

I tried create a issue to improvement for ObjectiveDDP for her OAuth connection that use NSURLConnection to improvement using NSURLSession but they said that if something that already work why change? So far i saw its not good we using a lib that don't want improvement her code.

@rodrigok
Copy link
Member

rodrigok commented Sep 2, 2015

@felipeflorencio awesome! It will be a new, and better, lib for DDP. Meteor needs this. I tried to create one project with this existing libs with the help of @rafaelks and it was very difficult to implement even very simple things.

Maybe with Switft 2 and some NoSQL database for iOS the work could be easier.

@engelgabriel will talk to MDG to try to get some help :)

@felipeflorencio
Copy link
Contributor

Soon they say to start we begin :D would be great. But just one point, use Core Data would be better, with Core Data we could get better from a database like that Apple always do full support and improvement.
I never implemented NoSQL database at my projects, but i actually work with one that was builded using SQLite that for mobile its almost the same idea or has the same restriction, some behavior points that we regret a lot is thread problems, zombie objects, always lock and we could get some issues, and when we tried update we always need do a huge efforts to get fit.

I don't know deep about NoSQL for sure, actually i'm a mobile guy, but tried implement another kinds of database as i saw so far was not a good idea guys ;)

@rodrigok
Copy link
Member

rodrigok commented Sep 2, 2015

@felipeflorencio how hard is to use Core Data for data with no defined schema?

I listened a lot about https://realm.io/

@felipeflorencio
Copy link
Contributor

Actually its really easy, and if want get more easier we could use some lib like MagicalRecord, you could see here : https://github.com/magicalpanda/MagicalRecord. Look how easy is create entity.

For all these i really like more Realm.io, its a product that they want get improvements and its good. But for a open-source project i believe its not a good way for us

@gsaslis
Copy link
Contributor

gsaslis commented Sep 2, 2015

wow -- isn't this a little out of scope for this project to build our own DDP impl??
I mean.. wouldn't that be putting this whole project on hold?

having said that, I've not tried using either of the 2 proposed libs, so I don't know how easy that would be.. will take a look as soon as possible...

@Sing-Li
Copy link
Member

Sing-Li commented Sep 2, 2015

wow -- isn't this a little out of scope for this project to build our own DDP impl??
I mean.. wouldn't that be putting this whole project on hold?

It may not be in this case. We don't need everything offered by DDP, and @rodrigok knows intimately what we need and the optimal format or way to get at it.

@rafaelks
Copy link
Contributor Author

rafaelks commented Sep 2, 2015

Honestly, I have no idea how much time it would take to us. But, the idea of writing a new Meteor client for iOS sounds interesting, mainly because currently implementations are written in Obj-C or in Swift but don't have mostly of methods that we need (1 & 2).

Of course we could get some of the current projects and contribute to, but since we're starting a complete new project in Swift 2, why not write a new DDP protocol wrapper in Swift 2 too? It actually could a complete separated project from this one, to be used by every other app that wants to use Meteor.

[1] - https://github.com/boundsj/ObjectiveDDP/blob/master/ObjectiveDDP/MeteorClient.m#L357-L371
[2] - https://github.com/martijnwalraven/meteor-ios: This one doesn't have the authentication methods, AFAIK.

@gsaslis
Copy link
Contributor

gsaslis commented Sep 14, 2015

Hi guys,
Just wondering if you've made any progress on your side with the whole DDP issue... ?

@rafaelks
Copy link
Contributor Author

I have not. IMHO if no one is working on that, we should start using an existent solution and then in a future, move to a made-in-home solution.

@gsaslis
Copy link
Contributor

gsaslis commented Sep 15, 2015

@rafaelks ok - sounds like a plan!

( i'm afraid I won't have a chance to look into the ddp speciifcs myself till next week though... : / )

@gsaslis gsaslis assigned gsaslis and unassigned rafaelks Sep 24, 2015
@kormic
Copy link
Contributor

kormic commented Sep 28, 2015

Hello there, I have started using objectiveDDP and I got an issue. There is a method called loginWithSessionToken that I use in order to resume the user's session when the app starts. I keep the session token from the previous login with nsuserdefaults and I try to login with that session cookie but I get an error:
Domain=boundsj.objectiveddp.transport Code=0 "You are not connected" UserInfo={NSLocalizedDescription=You are not connected}

I don't know if this is a problem with Rocket.chat or with the objectiveDDP. Could someone please check this? I also submitted an issue to objectiveDDP repo....

@kormic
Copy link
Contributor

kormic commented Sep 28, 2015

I found the problem.... boundsj/ObjectiveDDP#159 (comment)

@kormic
Copy link
Contributor

kormic commented Oct 20, 2015

I am working with the objectiveDDP for a while now and I 've managed to do a couple things. I can login, logout, get the meteor collections and some other stuff BUT I can't create a collection from the client like the web app does and according to objectiveDDP this is not possible. I think this is going to be a problem because the server streams the messages through the ChatMessage collection, that the client creates, so no collection no messages...

@engelgabriel
Copy link
Member

Hi @kormic

The objectiveDDP does just the DDP part of it includes the Mini-Mongo functionality?

Creating a client side only collection has nothing to do with DDP itself, it is Mini-Mongo's job.

@kormic
Copy link
Contributor

kormic commented Nov 13, 2015

@engelgabriel You have to excuse me because I am not a meteor.js expert and I m still digging into the code to understand a few things.

Right now the way I am getting the messages is by subscribing to "messages" + roomId. I found this in the /server/publications/messages.coffee. I am still trying to figure out how the client gets the messages. I talked with some guys and they told me that this publication is not used any more so I guess this is not the way I should do it. So while this is working for now, i don't know if it's the "right" thing to do. I would appreciate if someone could give me directions about how the client subscribes to each room's messages.

P.S.> I am watching some tutorials these days and I m starting to have a better understanding about meteor (it's awesome btw 😄 ). I see that you are using this package arunoda:streams so I guess this has to do something it. I must check more on this. I also have to check if I can implement this from the client side....Check this

@engelgabriel
Copy link
Member

Hi @kormic , you are right. We are using the arunoda:streams to send the messages. We avoided using pure subscriptions for server performance issues. But arunoda:streams are in fact built on top of regular subscriptions.

Did you try reading/following the DDP messages on the browser app inspecting the websocket messages on the network tab of the development tools in chrome?

Let me get @rodrigok and @rafaelks involved and discuss if you could use objectiveDDP to subscribe to a stream.

Did you try

Guys?

@kormic
Copy link
Contributor

kormic commented Nov 17, 2015

@engelgabriel ok, I had a look at the websocket messages and I see that they are coming in from the stream-messages collection. I also talked a little bit with @Sing-Li (thanks man!) who told me he was having the same problem with hubot. He told me how he did it so I will give it a try. I will let you know!

@rafaelks rafaelks closed this as completed Jul 6, 2016
@rafaelks rafaelks removed the 🚧 wip label Jul 6, 2016
@rafaelks rafaelks modified the milestone: v1.0.0 Sep 30, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants