Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

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:
    62
    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:
    345
    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:
    62
    thank for answer:)