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

How to multiple server connections at the same time #434

Closed
MTRNord opened this issue Dec 14, 2015 · 10 comments
Closed

How to multiple server connections at the same time #434

MTRNord opened this issue Dec 14, 2015 · 10 comments

Comments

@MTRNord
Copy link

MTRNord commented Dec 14, 2015

Hi I want to have the client connected to multiple servers without writing the hole handling stuff all over again. Are there any ways to do so?

@del6597
Copy link

del6597 commented Dec 14, 2015

The current implementation handles 1 server per client created. If you create another client in your code, then you'll have two bots connected to two servers.

@MTRNord
Copy link
Author

MTRNord commented Dec 14, 2015

@del6597 yeah that did I see but how can I make that both clients can use the same function? Is this in any way possible?

@jirwin
Copy link
Collaborator

jirwin commented Mar 10, 2016

@MTRNord You could just make your own addListener function that iterates your list of clients and adds the listener function to each of your clients.

Something like this maybe:

var client1 = Client(...);
var client2 = Client(...);
var clients = [client1, client2];

function addListener(event, callback) {
  clients.forEach(function(client) {
    client.addListener(event, callback);
  });
}

@MTRNord
Copy link
Author

MTRNord commented Mar 10, 2016

@jirwin i will try that :) thanks for the idea

@MTRNord
Copy link
Author

MTRNord commented Mar 10, 2016

@jirwin seems to work but hackint.org is sadly kicking the bot sometimes with "quit: Excess Flood" :/

@jirwin
Copy link
Collaborator

jirwin commented Mar 10, 2016

@MTRNord try enabling the floodControl option in the config.

@MTRNord
Copy link
Author

MTRNord commented Mar 10, 2016

@jirwin that seems to help :) hopefully i can speed up the forEach. it slows the bot extremly down

@jirwin
Copy link
Collaborator

jirwin commented Mar 10, 2016

@MTRNord do you have a code snippet you can share? I wouldn't expect things to slow dow much(other than flood control doing its thing)

@MTRNord
Copy link
Author

MTRNord commented Mar 10, 2016

@jirwin https://github.com/MTRNord/nordlab-hackerspace-door/blob/v0.0.2/handlers/irc.js
this is my code for the bot. I know that there are also other things that are slowing the bot down.

@jirwin
Copy link
Collaborator

jirwin commented Mar 24, 2016

Closing this.

@jirwin jirwin closed this as completed Mar 24, 2016
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

3 participants