Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multiple rooms #18

Open
ghost opened this issue Jun 29, 2015 · 5 comments
Open

Support multiple rooms #18

ghost opened this issue Jun 29, 2015 · 5 comments
Assignees

Comments

@ghost
Copy link

ghost commented Jun 29, 2015

No description provided.

@brodock
Copy link
Collaborator

brodock commented Sep 9, 2015

I have an idea on how to implement this in some simple incremental steps:

  1. use eventmachine to subscribe to multiple stream api endpoints: https://developer.gitter.im/docs/streaming-api
  2. automatically subscribe to endpoints listed here: https://developer.gitter.im/docs/rooms-resource#list-rooms
  3. in a future version, listen to events from faye endpoints: https://developer.gitter.im/docs/faye-endpoint

will give a try to the first point and report back when have it working

@ghost ghost assigned brodock Sep 13, 2015
@ghost ghost mentioned this issue Sep 13, 2015
@ghost
Copy link
Author

ghost commented Oct 23, 2015

Can you implement the first point? I don't fully understand how to do it with EventMachine.

@brodock
Copy link
Collaborator

brodock commented Oct 23, 2015

Yes, sorry for the delay... I will have enough time to contribute on the weekend.

I'm not 100% sure how to do, but I believe will be something based on faye channel subscription:
http://faye.jcoglan.com/ruby/clients.html, with the exception that for every "subscribed channel", instead of creating a loop or callback, will spawn/delegate using EM.defer to an EventLoop like the one present on RTMConnection: https://github.com/kenjij/lita-slack/blob/master/lib/lita/adapters/slack/rtm_connection.rb#L39

Does it make sense?

Eventmachine is an hybrid reactor-pattern implementation. While the main thread runs evented loop, you can spawn additional "worker threads" to perform different computations using EM.defer.

It would be really cool if @jimmycuadra could give a feedback here :)

@ghost
Copy link
Author

ghost commented Oct 23, 2015

I have tried to subscribe for multiple channels with Faye, but with no result.

Is multithreading really necessary for this? I prefer to avoid it.

@brodock
Copy link
Collaborator

brodock commented Oct 23, 2015

Lita already uses it (threads).

I have to read documentation again to fully understand whether defer is the right thing or how to use eventmachine own eventloop code correctly (I believe we will have to use something like Fibers).

The whole idea is that we need something to subscribe in an "evented way" to different endpoints and when it receives valid data, it should delegate tho the handlers in a non blocking way (this will use defer).

This last step is important because handlers can do heavy operations like remote IO, etc. If we don't isolate the handler from the eventloop, lita will have huge latency in crowded channels.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant