public void DoDisconnect(INetChannel channel, string reason) { Timer.Spawn(TimeSpan.FromMilliseconds(100), () => { if (!channel.IsConnected) { return; } // We do this so the client can set net.fakeloss 1 before getting ghosted. // This avoids it spamming messages at the server that cause warnings due to unconnected client. channel.SendMessage(new MsgGhostKick()); Timer.Spawn(TimeSpan.FromMilliseconds(100), () => { if (!channel.IsConnected) { return; } // Actually just remove the client entirely. channel.Disconnect(reason, false); }); }); }
/// <summary> /// Inform the server that the client has a complete copy of the /// mapping, and alert other code that the handshake is over. /// </summary> /// <seealso cref="ClientHandshakeComplete"/> /// <seealso cref="NetworkInitialize"/> private void OnClientCompleteHandshake(INetManager net, INetChannel channel) { LogSzr.Debug("Letting server know we're good to go."); var handshake = net.CreateNetMessage <MsgMapStrClientHandshake>(); handshake.NeedsStrings = false; channel.SendMessage(handshake); if (ClientHandshakeComplete == null) { LogSzr.Warning("There's no handler attached to ClientHandshakeComplete."); } ClientHandshakeComplete?.Invoke(); }