Results 1 to 3 of 3
  1. #1
    Briksins is offline Member
    Join Date
    Dec 2010
    Posts
    6
    Rep Power
    0

    Default 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!

  2. #2
    Grkn is offline Member
    Join Date
    Oct 2011
    Posts
    65
    Rep Power
    0

    Default 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

  3. #3
    Briksins is offline Member
    Join Date
    Dec 2010
    Posts
    6
    Rep Power
    0

    Default 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

  1. Replies: 0
    Last Post: 09-07-2011, 12:43 PM
  2. Replies: 1
    Last Post: 10-25-2010, 11:21 PM
  3. Replies: 9
    Last Post: 09-01-2009, 07:17 PM
  4. updating server side file using java bean
    By tskarthic in forum JavaServer Pages (JSP) and JSTL
    Replies: 3
    Last Post: 04-30-2009, 02:53 PM
  5. Replies: 1
    Last Post: 03-27-2009, 10:18 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •