Results 1 to 3 of 3
- 11-06-2011, 03:20 PM #1
Member
- Join Date
- Dec 2010
- Posts
- 6
- Rep Power
- 0
Java.NIO - Server Side -> Broadcast to all Active Clients
Hello!
I'm doing final year project for college - Online Game for Android
I'm stuck with one problem, how do I broadcast message to all actve clients?
I have no problem to respond back to client when it send message, but imagine that message from client belong to chat, his message should be brodcast to all clients to make it vissible for all users.
How do I switch the clients keys or channels of active connections manualy? or is there some other solution?
Many Thnx in advance!
- 11-16-2011, 08:37 PM #2
Member
- Join Date
- Oct 2011
- Posts
- 65
- Rep Power
- 0
Re: Java.NIO - Server Side -> Broadcast to all Active Clients
You have to design server and client for each phone.
A loop to listen all messages.
And event triggers like onClick,... to send messages.
But you have to use android service to send messages and you have to bind that service with other application components(bind()).
At least you have to know service lifecycle it is important in that case.
You can use one service to listen messages, it can be not binded service(startService()).
Some information related to service:>
startService() method to trigger services: Service can't be destoryed unless it destory itself or component that used service can destroy it.(It can run inifinitely).
binded services is destroyed automatically when related jobs have been finished by that service.
You can use both in service but it is not neccessary.
Server to listen :> start Type services (startService())
Client to send:> bind type services.
I guess it can be useful for you
- 11-16-2011, 09:28 PM #3
Member
- Join Date
- Dec 2010
- Posts
- 6
- Rep Power
- 0
Re: Java.NIO - Server Side -> Broadcast to all Active Clients
Hi, thnx for replay, my fault i didnt state my question fully. The server is separate, its not on the Android, it will be hosted on different machine
and the question was about exactly NIO library of java, which has a key on each event such "key.isReadable" "key.isWrtiebale", and so on... however i figure out how to get all clients information, it is stored in channel, which i start saving in Players class and after that im able to iterate it trough loop and send same message to each active client.
Similar Threads
-
Server side Java Developer for Games Studio (London, UK)
By kross in forum Jobs OfferedReplies: 0Last Post: 09-07-2011, 12:43 PM -
Single server, multiple clients - JAVA sockets, No threads
By sadishm in forum NetworkingReplies: 1Last Post: 10-25-2010, 11:21 PM -
Accessing local file from server side using Java Application
By ersachinjain in forum JDBCReplies: 9Last Post: 09-01-2009, 07:17 PM -
updating server side file using java bean
By tskarthic in forum JavaServer Pages (JSP) and JSTLReplies: 3Last Post: 04-30-2009, 02:53 PM -
How can i retain special characters in server side (java) after passing from client
By Malathi in forum Web FrameworksReplies: 1Last Post: 03-27-2009, 10:18 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks