3

I'm currently working on a project where the infrastructure must look like this:

[Client 1] ----------- [Server] ----------- [Client 2]

Client 1 must activate a button, which would trigger an event on the server. Then, client 2 must listen for that specific event to show the value.

For instance, Client 1 would be a tablet, with a simple button that would have an ID of 1, let's say.

I have to be able to show on Client 2, let's assume a TV plugged on a linux (Raspberry Pi) machine, that button ID 1 was pressed on the tablet.

How would you implement that architecture, using only HTML for the display of Client 1 and 2, javascript for communicating between server and clients and NodeJS as a server core?

Any idea will be welcome, I tried to implement it but my logic failed me at some point! :)

Max Methot
  • 128
  • 6
  • 3
    [Meteor](http://www.meteor.com/) and [Derby](http://derbyjs.com/) are node frameworks that implement the client-server functionality you are asking for. – Explosion Pills Oct 22 '13 at 21:56
  • 1
    Thanks to you, that seems to go towards what I'm looking for. I'll definitely give them a go! – Max Methot Oct 23 '13 at 12:17
  • 1
    Oh, I just realized that Meteor ins't supported on the Linux architecture I am trying to implement, which is ARM on a Raspberry Pi. Forgot to mention it at first, I edited my initial question. – Max Methot Oct 23 '13 at 13:09

1 Answers1

3

It seems that what you describe is real-time functionality. What you are describing is essentially similar to a chat system, only a little more fine-grained and structured. It is not a matter of what technology you use to present it, but rather the protocol you use to communicate between the clients and the server.

Normally HTTP is not very well suited for real-time applications. A technology which tries to solve the problems you have is WebSockets. NodeJS supports WebSockets and new browsers also do, so you can look around for different libraries and implementations. Just have in mind that when using the WebSockets protocol, the tools that you use on the client depend on the ones you use on the server and vice versa.

You can take a look at Socket.io as an example. For further pointers, you can take a look at this question: Which websocket library to use with Node.js?

Many libraries provide one additional layer of abstraction over WebSockets and let you implement real-time functionality without caring about the underlying protocol. The Meteor framework mentioned in one of the comments is such a thing - it uses WebSockets and HTTP under the hood, depending on what you do.

It is all a matter of how much control you want. You have to know how much work you want to do yourself and how much you want done for you by a third party.

Community
  • 1
  • 1
Slavo
  • 15,255
  • 11
  • 47
  • 60
  • 1
    Thanks for your detailed answer Slavo, I really appreciate it. I have given a go with Socket.io and so far I find it the most easy to use amongst all. I still am having trouble trying to figure out how to achieve what I wanted, but that's another problem of mine and I know I am on the right track! :) – Max Methot Oct 24 '13 at 11:40