V
V
Vladislav2014-09-22 20:21:10
JavaScript
Vladislav, 2014-09-22 20:21:10

What is the best way to implement client-server chat on java websocket?

The fact is that at first I just wrote a multi-threaded chat on standard java sockets (server sockets) and a console client for checking, but when I needed to write a web client, I realized that web sockets were needed. And so now I decided to rewrite on web sockets. So far I'm thinking of using these technologies
Server:
-java (web socket)
-tomcat 7
-postgresql
-maven
Client:
-JavaScript: AngularJS, and possibly jQuery

But I still don't know how to implement web sockets on the server, maybe there are some examples and what use the library for web sockets, because I looked and there are quite a few of them.

Answer the question

In order to leave comments, you need to log in

5 answer(s)
B
bromzh, 2014-09-22
@bromzh

It is better to take SockJS as a client, because it is much more flexible: it automatically replaces websockets with a technology supported by the browser (long polling, flash, file upload, etc.), automatically changes ports if the required ones cannot be used. At the same time, it does all this transparently, the messaging code will be exactly the same as in the case of ordinary web sockets.
This library is definitely supported by SpringFramework. I don't know about pure Java EE. Therefore, you have 2 options: use websockets from spring, and otherwise use Java EE features, it seems like there are a lot of tutorials on how to cross EJB and Spring. Well or use completely Spring instead of Java EE.
And if you know exactly what browser users will have, then you can stir up everything on pure web sockets and Java EE.
PS Do not use tomcat, take full-featured servers: Glassfish 4 or WildFly 8 (former JBoss).

A
Alexander Taratin, 2014-09-22
@Taraflex

socket.io client
Server https://github.com/mrniko/netty-socketio
And you can also not rewrite anything and use flash on the client, it can connect to normal sockets.

P
ponkin, 2014-09-23
@ponkin

My 5 cents:
Can be used instead of tomcat Jetty .

S
SergTito, 2017-08-04
@SergTito

In fact, all such questions have already been discussed several times here t.me/springframeworkio

F
FanKiLL, 2014-09-23
@FanKiLL

netty.io We used to write a server on it with webcosket's

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question