Reputation: 7652
I am building a java chatting web application.(Server and Client in one project)
follow is my condition
So User scenario in my head is
I am quite confusing with step4. Is it possible that Java calls DOM event trigger?
How could a client get a new message event from server?
Thanks. :D
P.S. These days majority of chatting servers are event-driven. Is it possible to build an event driven chatting server with Java?
Upvotes: 3
Views: 1395
Reputation: 125
Your solution is formed as if there is no WebSocket technology available to you. WebSocket is implemented to solve real time messaging issues. It pushes message to the destination.
But if to stick wih your method following is meaningful. You need someplace to keep incoming messages such as database or session.setAttribute [bad idea]. Then use some ajax call loop on the clients machine to ask for a new incoming message from server. Probably your server will slow down due to incoming flood of GET requests from multiple users.
to Your last question in post scriptum: yes, I use tomcat websocket api.jar in my projects. There is well written documentation on apache.org
As I mentioned, learn WebSocket if your users are not using old internet explorer browsers. There are bunch of tutorials on it...
Upvotes: 2