1

I'm writing an application in Java that reads sensor data and I want to show this data in real-time to a number of clients (in their browser). In order to accomplish this I already have an servlet using the atmosphere framework to communicate using web-socket if possible (and fall back to long-polling if not). On the other hand I have a java class that constantly read's in and interprets the sensor data.

However this question is not about web socket but how can I merge these two programs? I have little experience with servlets. As far as I can tell every time a client connect a new instance of the servlet is dispatched but I don't want a new instance of my data gathering program; I want this data gathering program to communicate to all the clients (and their servlets). Is this possible?

edit: The data gathering program is actually reading from a serial port and decoding it's data (data over serial port is encryped using special protocol).

Thomas
  • 1,678
  • 4
  • 24
  • 47
  • Take a look to http://stackoverflow.com/questions/14765053/java-based-library-for-sensor-data-collection – Mihai8 Feb 28 '13 at 12:03
  • Hm; not really what I'm looking for. I'm not looking for a framework :) I'm not working with raw data; i'm working with specific data that changes the user-interface; but data needs to be live hence the use of websockets – Thomas Feb 28 '13 at 12:05
  • There's one instance of a servlet per mapping, but that's not relevant. You can either put the sensor reader into the Web app and share data directly, or queue up the data somewhere and read it in the Web app. The are a ton of ways to do this. – Dave Newton Feb 28 '13 at 12:08
  • thx but how?; what do you mean by "put the sensor reader into the Web app"? or "Queue up the data somewhere" in Java terms? – Thomas Feb 28 '13 at 12:10

0 Answers0