Няма описание

Lucas Stadler c452ef5918 add convenience function to create listeners. преди 11 години
..
public c452ef5918 add convenience function to create listeners. преди 11 години
.gitignore 76eb7fa979 add the simplest archiver possible. преди 11 години
README.md cb4b163be6 having rooms and names would be nice. преди 11 години
archiver.js 76eb7fa979 add the simplest archiver possible. преди 11 години
package.json 6a0bd40c8b try serving http and ws from the same server. преди 11 години
server.js 6a0bd40c8b try serving http and ws from the same server. преди 11 години

README.md

babl

a simple, web-based chat server using websockets.

running it

$ npm install
$ PORT=10001 node server

The server is now running on http://localhost:10001.

You can also archive all messages ever sent:

$ HOST_URL=ws://localhost:10001 node archiver

This allows clients to load the previous messages on initial load.

ideas

  • starting out should be as easy as possible
    • start with a purely client-side bot/script
      • who will answer on the client? the logged in user or a user-specific bot?
    • use same api on server
      • still, some things aren't possible on the client (unrestricted http requests, file writing or custom protocols)
  • would be cool to support images & youtube videos via the same (client-side) api, possibly even audio or canvas?
  • don't want to reinvent security, protocols... is it possible to use hubot? (setup is quite complex, need to understand quite a few different parts)

wishlist

  • how do we websocket efficiently? should we batch (both client and server), should/could we send binary?
  • rooms. separate sockets or multiplex via one socket? then we'd need some mechanism to list rooms, create them, optionally set a passphrase or possibly other fancy things.
  • names. and maybe other "properties". we could handle this using a separate service that has mappings from the generated name to the properties. clients could then decide to use that if they so desire.

api playground

here are some ideas how the api could look.

// client-side
var chat = document.querySelector("#chat");

babl.on('connection', function(conn) {
    conn.on('message', function(msg) {
        var display_msg = msg.user + "(" + msg.timestamp + "): " + msg.text;
        chat.textContent += display_msg + "\n";
    });
});