Search Unity

LLAPI: Appending data to connect and disconnect events

Discussion in 'Multiplayer' started by Panzerhandschuh, May 21, 2016.

  1. Panzerhandschuh

    Panzerhandschuh

    Joined:
    Dec 4, 2012
    Posts:
    17
    Is it possible to send additional data when connecting to or disconnecting from a server? I would like to make it so when a client connects to a server with a password, the client can immediately send a password for authorization. Also, I would like for the server to be able to append data to a disconnection to notify the player why they were disconnected (ex: password authorization failed, kicked, banned, etc).

    I have tried this on the server-side to disconnect clients that send an incorrect password:

    Code (csharp):
    1. byte[] buffer = new byte[] { (byte)NetworkMessage.AuthorizationFailure };
    2. byte error;
    3. NetworkTransport.Send(hostId, connectionId, NetworkManager.reliableChannel, buffer, buffer.Length, out error);
    4. Disconnect(connectionId);
    But the disconnect event always gets received by the client before the authorization failure network message. I could just remove the server-side disconnect call and make the client disconnect themselves when the client receives the AuthorizationFailure message, but this can be exploited without adding more security measures (the client can just ignore the AuthorizationFailure message to avoid disconnection). It would be much easier if I could attach the data to the same packet used to send the disconnect event to the client.
     
    Nevak, thegreatzebadiah and crezax like this.
  2. crezax

    crezax

    Joined:
    Mar 19, 2013
    Posts:
    12
    Bump, having exact same issue
     
  3. Nevak

    Nevak

    Joined:
    Sep 27, 2012
    Posts:
    20
    Exactly the same here.

    Still researching
     
  4. HiddenMonk

    HiddenMonk

    Joined:
    Dec 19, 2014
    Posts:
    987