call peer.disconnect right after peer.opcustom

what is the best way to send player a message and then disconnect them right the way? do I need to create a timer to wait for a few seconds to make sure the message is sent or engine will execute in order ?

eg:
peer.opcustom("message"); // is this 100% going to happen ?
peer.disconnect(); // at client side, is this 100% going to happen after receive the message ?

Comments

  • Hi @Aevin,

    you can call SendOutgoingCommands(); on the LoadBalancingPeer after using OpCustom. This will send pending events.
  • @Christian_Simon sorry my bad. i used wrong function, (SendOperationResponse, not opcustom)

    here is what i would like to know:
    at server side, i would like to disconnect a client after a message is sent.
    so this is what i did:
    peer.SendOperationResponse(message);
    peer.disconnect();

    with these 2 lines of server side code, i would like to know what is going to happen at client side ?
    1: am i going to receive this message at 100% chance ?
    2: disconnect is going to happen after receive message ?
  • Moved.

    @vadim or @chvetsov might help.
  • hi, @Aevin

    on the server side, there is no way to know that the message was delivered. so, we use peers timer to schedule disconnect. it will look like this:

    peer.SendOperationResponse(message);
    peer.RequestFiber.Schedule(peer.disconnect(), 3000);

    best,
    ilya