public static Close ( |
||
sock | ||
Résultat | void |
/// <summary> /// SV_DropClient /// Called when the player is getting totally kicked off the host /// if (crash = true), don't bother sending signofs /// </summary> public static void DropClient(bool crash) { client_t client = Host.HostClient; if (!crash) { // send any final messages (don't check for errors) if (Net.CanSendMessage(client.netconnection)) { MsgWriter msg = client.message; msg.WriteByte(Protocol.svc_disconnect); Net.SendMessage(client.netconnection, msg); } if (client.edict != null && client.spawned) { // call the prog function for removing a client // this will set the body to a dead frame, among other things int saveSelf = Progs.GlobalStruct.self; Progs.GlobalStruct.self = EdictToProg(client.edict); Progs.Execute(Progs.GlobalStruct.ClientDisconnect); Progs.GlobalStruct.self = saveSelf; } Con.DPrint("Client {0} removed\n", client.name); } // break the net connection Net.Close(client.netconnection); client.netconnection = null; // free the client (the body stays around) client.active = false; client.name = null; client.old_frags = -999999; Net.ActiveConnections--; // send notification to all clients for (int i = 0; i < Server.svs.maxclients; i++) { client_t cl = Server.svs.clients[i]; if (!cl.active) { continue; } cl.message.WriteByte(Protocol.svc_updatename); cl.message.WriteByte(Host.ClientNum); cl.message.WriteString(""); cl.message.WriteByte(Protocol.svc_updatefrags); cl.message.WriteByte(Host.ClientNum); cl.message.WriteShort(0); cl.message.WriteByte(Protocol.svc_updatecolors); cl.message.WriteByte(Host.ClientNum); cl.message.WriteByte(0); } }
/// <summary> /// CL_Disconnect /// /// Sends a disconnect message to the server /// This is also called on Host_Error, so it shouldn't cause any errors /// </summary> public static void Disconnect() { // stop sounds (especially looping!) Sound.StopAllSounds(true); // bring the console down and fade the colors back to normal // SCR_BringDownConsole (); // if running a local server, shut it down if (Cls.demoplayback) { StopPlayback(); } else if (Cls.state == ClientActivityState.Connected) { if (Cls.demorecording) { Stop_f(); } Con.DPrint("Sending clc_disconnect\n"); Cls.message.Clear(); Cls.message.WriteByte(Protocol.clc_disconnect); Net.SendUnreliableMessage(Cls.netcon, Cls.message); Cls.message.Clear(); Net.Close(Cls.netcon); Cls.state = ClientActivityState.Disconnected; if (Server.sv.active) { Host.ShutdownServer(false); } } Cls.demoplayback = Cls.timedemo = false; Cls.signon = 0; }