Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Implementing a chat server as a WebService

I have a school project in which I have to implement a chat application, whose server will be a java web service.

The problem is that I've always thought of a web service as a way of calling remote functions, and I have no idea how to keep a "session" active on the web service, nor how to keep track of all the people currently in chat, rooms etc.

like image 303
MeLight Avatar asked May 24 '09 08:05

MeLight


People also ask

Is chat a Web service?

A chat service is any online service or technology that enables text messages to be translated in real time between participants. Often used in customer service as “live chat,” chat services connect a customer service agent with a customer for a real-time, instantaneous conversation.

How does chat server work?

Messages that are entered in the Chat window are sent to the destination via the chat server. In a chat environment, therefore, the personal computer that runs the chat server can be considered the server and a personal computer that is connected to the chat server can be considered a client.

What is chat application system?

A chat application makes it easy to communicate with people anywhere in the world by sending and receiving messages in real time. With a real-time chat app, users are able to receive the same engaging and lively interactions through custom messaging features, just as they would in person.


2 Answers

To the best of my knowledge, a chat server is supposed to know its clients after an initial connection, and send every client message to all clients. This definitely calls for some sort of session maintenance. I think the right way to do this is as follows:

  1. Client calls web service 'handshake' and provides some minimal identification details.
  2. Server returns an acknowledgment that includes a unique client identifier.
  3. Client calls web service 'message' and sends a new message, together with its identifier.
  4. Server identifies client by the identifier, distributes message to all clients.

I'm not really sure how the message distribution should work, as web services are essentially a pull-service and not push. Perhaps the client should expose its own web service for the server to call.

Hope this helps,

Yuval =8-)

like image 65
Yuval Avatar answered Oct 23 '22 19:10

Yuval


You could consider implementing a COMET solution. This will effectively give you push communication, thus eliminating latency, a VERY nice feature for a chat application.

If you want to go for the gold, consider implementing more advanced features:

  • spell check
  • URLs/email addresses converted to links automatically
  • separate chat rooms
  • moderator functions (terminate chat, kick user)
  • event info like "User is typing..."
  • statuses (available, busy, away...)
  • avatars
  • ...
like image 29
D'Arcy Rittich Avatar answered Oct 23 '22 19:10

D'Arcy Rittich