Page MenuHomeFeedback Tracker

ClientDisconnectedEventTypeID unreliable for detecting client disconnects
Assigned, UrgentPublic

Description

The ClientDisconnectedEventTypeID event is a useful way for mods to detect when clients disconnect from the server, for managing state, etc. However, the ClientDisconnectedEventTypeID event is not sent if the disconnecting client is not bound to any SurvivorBase instance.

The following modification of the MissionServer script class can be used to demonstrate the issue:

modded class MissionServer
{
    override void OnEvent(EventType eventTypeId, Param params)
    {
        if (eventTypeId == ClientDisconnectedEventTypeID)
        {
            ClientDisconnectedEventParams par = ClientDisconnectedEventParams.Cast(params);

            PrintFormat("Client disconnected => %1 %2 %3 %4", par.param1, par.param2, par.param3, par.param4);
        }

        super.OnEvent(eventTypeId, params);
    }
};

Under normal circumstances, the above code will generate the following script log output when a player disconnects:

SCRIPT       : Client disconnected => PlayerIdentity<a9058060> SurvivorBase<ad9a34e0> 15 0

If a client disconnects without a bound SurvivorBase instance, no such log is output.

Intuitively, it feels like the ClientDisconnectedEventTypeID event should be sent in this situation, with a valid, non-NULL PlayerIdentity instance as param1, but with NULL as param2.

Details

Severity
Minor
Resolution
Open
Reproducibility
Always
Operating System
Windows 10 x64
Operating System Version
21H1
Category
General
Steps To Reproduce

There are a couple of different ways to reproduce this bug. The first is to bury a dead player's body and have the corresponding client disconnect without respawning, first:

  1. Client A connects to server as Player A
  2. Client B connects to server as Player B
  3. Player A is killed
  4. Player B buries Player A's dead body (this deletes the SurvivorBase instance bound to Client A)
  5. Client A disconnects from server from the "You are dead" screen

Another way to reproduce the bug by letting the server automatically clean up your own corpse and then disconnect without respawning, first:

  1. Configure server to set a very short CleanupLifetimeDeadPlayer in $mission:db/globals.xml
  2. Client A connects to server as Player A
  3. Player A is killed
  4. Client A waits at the "You are dead" screen for at least CleanupLifetimeDeadPlayer seconds (so that their corresponding SurvivorBase instance is deleted)
  5. Client A disconnects from server from the "You are dead" screen
Additional Information

Tested with DayZ 1.14.154258

Is there a more reliable event (or some other functionality) for server mods to detect when clients disconnect?

Event Timeline

tjensen created this task.Nov 6 2021, 7:14 PM
Geez changed the task status from New to Assigned.Nov 8 2021, 12:30 PM