Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Resolved How to understand the connection status of a networkconnection on the server?

Discussion in 'Unity Transport' started by Farshadfarzan368, Aug 10, 2023.

  1. Farshadfarzan368

    Farshadfarzan368

    Joined:
    Sep 10, 2022
    Posts:
    73
    How to understand the connection status of a networkconnection on the server? I wanted to check if a networkconnection is connected or disconnected?
     
  2. simon-lemay-unity

    simon-lemay-unity

    Unity Technologies

    Joined:
    Jul 19, 2021
    Posts:
    441
    I'm not sure what you mean by understand the connection status? You can get the current status of a
    NetworkConnection
    like this:
    Code (CSharp):
    1. var status = driver.GetConnectionState(connection);
    This will return a
    NetworkConnection.State
    value, which on the server can be either
    Connected
    or
    Disconnected
    (
    Connecting
    is for clients only). These states mean exactly what their name implies. When a connection is closed (goes from disconnected to connected), you'll also get a
    Disconnect
    event through
    PopEvent
    . Newly-connected connections are obtained through the
    Accept
    call.
     
  3. Farshadfarzan368

    Farshadfarzan368

    Joined:
    Sep 10, 2022
    Posts:
    73
    thank for answer:)