Skip to content

Send Data To Client

徐昊 edited this page Feb 14, 2019 · 5 revisions
  • Send To All
    //After listen
    IClientPool pool = mServerManager.getClientPool();
    pool.sendToAll(/* Which will be send */);

You must call getClientPool() Method behind call listen() otherwise it will return null.

  • Send To Some One
    //After listen
    IClientPool pool = mServerManager.getClientPool();
    //The tag you have set.If you never set the tag, the IP address will be the default tag
    IClient client = pool.findByUniqueTag("192.168.1.1");
    if(client != null){
        client.send(/* Which will be send */);
    }

Maybe the client is null When the client is disconnected