What I am after is a test implementation of a TCP server with RUBY on RAILS that we can use in the existing application. I want a Proof Of Concept implementation to show us how to do this properly. As such, we need basic control only, but we should be able to take your work and extend it.
In the existing project we have a list of a number of 'Lights'. Attached to each 'Light' is a 'Light Switch', which is a button on a web interface. When the user clicks on the Web interface for a light, we want the light to toggle. In our case the light is controlled via TCP. Each light will connect to a RUBY based TCP server, and stay connected. Once it connects, it will identify by the ID number of the light. Authentication is done by the fact it knows a valid ID number. The light will then stay connected. Then, whenever user changes the switch, the client will get a command via TCP saying "Light On" or "Light Off" as appropriate. In other words, notifications are pushed to the TCP server.
We have an implementation where a new TCP connection is made from the RAILS application to the TCP server every time the light switch changes, but think this can be done in a smarter way. We want to hear your ideas. Ideally some sort of database queue would be used as the communication mechanism. Please bear in mind that we may get to the point where we have hundreds of light switches, and want to make things as intelligent as possible