Skip to content

Conversation

@acostarelli
Copy link
Contributor

No description provided.

setMessageListener is a new method that is aiming to replace the message queue system. When you call it, you can pass in a set of types. These types describe the kinds of messages that the listener should respond to if received. For example, if you did:

CardshifterServerAPI.setMessageListener(function(message) {
     ...
}, ["chat", "userstatus"]);

Then, every time a message was received and it's .command is either "chat" or "userstatus", then the function passed in will be called and the received message will be passed in.
This command map is an object where the keys are the .command s of messages, and the values are functions. When a message is received, it's command is used to find the function to call that will act on the newly received message. This is definitely much more structured and cleaner than the old lobby controller.
addEventTypes -- add new event types to the event types listener

removeMessageListener -- remove the message listener
acostarelli pushed a commit that referenced this pull request Aug 8, 2015
API 2.0; now, instead of hiring a mailman, you set a message listener
@acostarelli acostarelli merged commit d187891 into master Aug 8, 2015
@acostarelli acostarelli deleted the new-api branch August 9, 2015 23:29
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

Successfully merging this pull request may close these issues.

1 participant