Question

I am currently building a chat server (meebo style).

The architecture is something like this.

  1. Bitlbee over libpurple is on host B. Its a trivial server on data center.
  2. User communicates with bitlbee via web server (just like meebo) on Host A. The backend of this web server maintains chat session. It just translates the user commands to proper bitlbee comamnd and sends back to host A.

The most important part here is that host A will be deployed in embedded Linux.

I have 2 questions.

  1. To keep the chat session persistent I am thinking of using . As its much more easier to create a real time application with persistent connection. But I doubt if its supported in such platform.
  2. If I use C instead of node.js (I am not using any web server) I can talk to the irc server at host A by libirc. But how do I implement all the web server features in C (like session, url/cookie/post data parsing etc) ?

Also if you think my approach is wrong or there is a better approach please tell me how can I improve this architecture?

Note: This is NOT a high volume chat server.

Was it helpful?

Solution

If building V8/Node.js is prohibitive on the embedded platform, the next best thing would be to take the event loop and platform layer (libuv) and HTTP parser (http-parser) of Node, both written in C and use those as a starting point. These are the same libraries used to build Node.js so they are battle tested and will give you the performance characteristics you seek.

Ryan Dahl, author of Node.js, demonstrates exactly how to use libuv and http-parser to build an asynchronous web server in C.

OTHER TIPS

Put a ZNC server between Bitlbee and the web-based IRC client. Bitlbee will think that the user has never logged out and ZNC can maintain a backlog of messages until the user connects again with the web client.

I would try to go with node.js if that is your choice, also what embedded system is it? As knowing that would help more. Also, another plus for node.js is that it does have session handling built it, but if you wanted to do it in C try and see if you can get a sqlite wrapper running on the embedded device to store the session information.

But, if possible stick to something with less work on embedded devices, feels bad to reinvent a lot of stuff or have to fiddle with compile issues for your device.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top