javascript - How to stream Data in with java websockets -


i read tutorials or tried have js code connects java websocket , when click on button sends test string websocket , reciev other.

now wanna have realtime stream in string js code recieves current time in milliseconds how can achiev don't know every second new time ? maybe better idea use normal time instead of milliseconds can change this.

my codes far javascript

var websocket; $(document).ready(function(){     websocket = new websocket("ws://localhost:8080/timestreamingtestartid-1.0-snapshot/websockets/simplestockmarket")      websocket.onopen = function(){      alert("sucess: registered!!");     }  $("#start").click(function(){      websocket.send("test")     websocket.onmessage = function(erg){     console.log(erg);     }  });  }); 

my java websocket code

@serverendpoint("/websockets/simplestockmarket") public class simplestockmarketwsserverendpoint {  @onopen public void open(session session) {   }       @onmessage     public void message(session session,string message) {          try {   session.getbasicremote().sendtext(long.tostring(system.currenttimemillis())+" <- time, message client -> "+message);         } catch (ioexception e) {             e.printstacktrace();         }  }  @onclose public void close(session session) {  } } 

i know it's not finished yet wanna achiev streaming before rest closing connection again. if missed important please tell me , add it.


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -