Node Chat

From BlueLine Games Wiki
Jump to: navigation, search

TODO: THINK OF A NAME FOR THE PROJECT! Maybe even get a logo. That'd be cool.

History

While working at Wikia, I made a node.js Chat server that integrated with Wikia (MediaWiki) accounts. Since Wikia code is open source, I forked the original code and (keeping the same MIT license) started making the chat-code general purpose while building Elsewhere.

Wikia is one of the most popular sites in the United States (currently #16, right below Wikipedia) so the server has already had the chance to be put under serious stress-testing and has been incrementally improved over the years since it was released.

Goals

  • Make a highly scalable node chat server that can be plugged into existing sites.
  • Continue using each site's authentication systems so that the users don't have to log in to chat separately.
  • Make it easy to configure a new site to use this server (1 hour setup maximum).
  • Reorganize the code so that everything site-specific can be easily configured & get both Wikia and Elsewhere to run on this.
  • Keep the latest stable version of the project running on both Wikia and Elsewhere.

Documentation

These might need to be merged. These are the docs from Wikia: Node Chat/Docs

Code & License

The code on Github and is licensed under the MIT License.

Backend

Frontend

When you have the node.js server running, you will probably want need some front-end website code to put widgets on your site which point your users to the chat, and you'll need some code to let the chat server authenticate the user using your site's auth system.

We don't have a good generalized front-end example yet... but here's the front-end Wikia code for reference:
https://github.com/Wikia/app/tree/dev/extensions/wikia/Chat2

TODO: Add some default front-end code in a directory in the main github repo. This will be unused by most actual installations, but they can copy/paste it to the right spot in their own projects.

Integration

TODO: Instructions on how to check this project out in a way that you can use the same Model javascript between your site and node servers.

Setup

THESE INSTRUCTIONS WILL NEED A LOT OF WORK!

  1. git clone the Respository to where you want the code to go (and create a branch if you want to modify the code... you can always do that later if you are unsure).
  2. OPTIONAL: set the WIKIA_CONFIG_ROOT environment variable to a directory where your config will be (by default, the config is in the root directory).
  3. Copy the ChatConfig_EXAMPLE.json to ChatConfig.json and update it with reasonable settings (eg: everything localhost to start with).
  4. run "node server.js" and fix bugs until it works ;) as I'm doing that I'll be filling in this "Setup" list and making Cleanup tasks below.

Refactoring Needed

This section will be for tracking the changes needed to make the Wikia/MediaWiki system able to be used generally on other sites (while still running cleanly on Wikia).

  1. Make the process.env.WIKIA_CONFIG_ROOT not have the word Wikia in it (maybe fall back to the Wikia version so that we don't have to update the env on the Wikia chat servers to work with the new code).
  2. Make installer-script which will create the default ChatConfig.json and if someone tries to run the server when that json file doesn't exist, instruct them to run the install script. Install script should ask for settings (but have defaults for all of them) and do a reasonably cryptographically-secure job of generating the secret code (otherwise someone can attack the server based on knowing what day the chat server went live & trying all of the seconds).
  3. Add some project-branding somewhere which is on by default (but probably set it to be turned off on Wikia... ask them about that).
  4. In Wikia, delete Chat2/docs/chat.sql for cleanliness (it's just the schema for the little PHP prototype we made)
  5. Refactor WMBridge to be SiteBridge and mwBridge to be siteBridge in Chat (WMBridge sounds like some dyslexia anyway). For Wikia's distribution, have it be MwSiteBridge (and just a swapped require() call to get that instead of the default SiteBridge).
  6. Need to make the NodeApiClient more general (eg: not MediaWiki specific) and should make the name of that and the nodeInterface more obvious so it's clear that the client talks to the node server's API where as the nodeInterface answers questions FROM the server.
  7. ChatConfig.json is duplicated! We have one in /node/ChatConfig.json and one in /public_html/NodeChat/ChatConfig.json... make one of these able to be read by both node and PHP. When there are two, they have to be kept in sync which is bad bad bad.
  8. ChatHost
    1. Right now, it's not documented, but the frontend ALWAYS connects to ChatHost. This is a security feature so that only 1 port has to be open on the chat servers & we can easily add chat instances without reconfiguring the firewall. There is some haproxy config on the ChatHost that redirects to the appropriate ports based on rules. Document this. Example dev-box rules are in PRIVATE/Cloud Servers/chat_haproxy_example.txt
    2. haproxy isn't easy in Windows, so I just set the ChatHost port to be the same as Instance 1, so there really is only 1 working instance possible on Windows devboxes right now.
    3. Ideally, we could make a way to do the rewriting on windows devboxes also... in the meantime we need to make it clear that Windows devboxes only do one instance.