Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have created an one to one chat application using HTTP connection (In this method each and everytime you want to send message, you have to call the webservice and for receive message, you continously need to call the webservice using Timer).Now I want to implement group chat app.Can some one please tell me how to go about with it. kindly help
Posted
Comments
Richard MacCutchan 9-Nov-14 7:33am    
There are many articles on this subject that Google will find for you.
akshaya srinivasan 9-Nov-14 7:36am    
I am not able to find one for my situation.Can you please tell me.
Afzaal Ahmad Zeeshan 9-Nov-14 7:46am    
Look at my Solution 1. It has basic explaination of the core features that are required by a "modern day chat system". You don't want to start a ticker that runs each and every second in the CPU and to load the data by that. There are better services than those old methods.

1 solution

First thing that I forced me to answer this question was, you said "continously need to call the webservice using Timer". Why? It is not a good user experience for most of the Android users. I am having an Android mobile phone that has only 128mb Ram and a single core processor and I just don't want to use any of the application that would cause my CPU to run at the speed of Usain Bolt.

You need to understand the concept of Push technology[^]. This service is used to initiate a connection and the data is sent by the server to the client without the client having to request. Request made by client to get the data is called Pull. This method is usefull, since the User's system's CPU is not used in this method of chatting service. A message is sent by the server directly without having to request and things work like a "magic". Facebook, WhatsApp and many more use this feature.

A group is a bunch of people who're grouped (by a unqiue identifier). In this case, you can create a simple GUID to identify the ID of the group of the people and then let people add their fellows to this group, save their profiles (userids) in your database. Upon sending the data, send its one copy to each of the user in that group (..each of the user with that GUID of the group).

Here[^] is a documentation for Android developers to learn about Google Cloud Messaging for Android.

Quote:
Google Cloud Messaging (GCM) for Android is a service that allows you to send data from your server to your users' Android-powered device, and also to receive messages from devices on the same connection.


Good luck!
 
Share this answer
 
Comments
akshaya srinivasan 9-Nov-14 7:45am    
can you please tell me if tcp socket or datagram socket would be better for group chat?
Afzaal Ahmad Zeeshan 9-Nov-14 7:47am    
Tcp sockets are sockets used to send the data, you can use any method that you like to send/recieve the data. This depends on your requirement. You can compare their features and see which one you would be using.
akshaya srinivasan 9-Nov-14 7:48am    
thank you!!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900