public static SendToAll ( MsgWriter data, int blocktime ) : int | ||
data | MsgWriter | |
blocktime | int | |
return | int |
/// <summary> /// SV_SendReconnect /// Tell all the clients that the server is changing levels /// </summary> private static void SendReconnect() { MsgWriter msg = new MsgWriter(128); msg.WriteChar(Protocol.svc_stufftext); msg.WriteString("reconnect\n"); Net.SendToAll(msg, 5); if (Client.cls.state != cactive_t.ca_dedicated) { Cmd.ExecuteString("reconnect\n", cmd_source_t.src_command); } }
/// <summary> /// SV_SendReconnect /// Tell all the clients that the server is changing levels /// </summary> private static void SendReconnect() { MessageWriter msg = new MessageWriter(128); msg.WriteChar(Protocol.svc_stufftext); msg.WriteString("reconnect\n"); Net.SendToAll(msg, 5); if (Client.Cls.state != ClientActivityState.Dedicated) { Cmd.ExecuteString("reconnect\n", cmd_source_t.src_command); } }
/// <summary> /// Host_ShutdownServer /// This only happens at the end of a game, not between levels /// </summary> public static void ShutdownServer(bool crash) { if (!Server.IsActive) { return; } Server.sv.active = false; // stop all client sounds immediately if (Client.cls.state == cactive_t.ca_connected) { Client.Disconnect(); } // flush any pending messages - like the score!!! double start = Sys.GetFloatTime(); int count; do { count = 0; for (int i = 0; i < Server.svs.maxclients; i++) { HostClient = Server.svs.clients[i]; if (HostClient.active && !HostClient.message.IsEmpty) { if (Net.CanSendMessage(HostClient.netconnection)) { Net.SendMessage(HostClient.netconnection, HostClient.message); HostClient.message.Clear(); } else { Net.GetMessage(HostClient.netconnection); count++; } } } if ((Sys.GetFloatTime() - start) > 3.0) { break; } }while (count > 0); // make sure all the clients know we're disconnecting MsgWriter writer = new MsgWriter(4); writer.WriteByte(Protocol.svc_disconnect); count = Net.SendToAll(writer, 5); if (count != 0) { Con.Print("Host_ShutdownServer: NET_SendToAll failed for {0} clients\n", count); } for (int i = 0; i < Server.svs.maxclients; i++) { HostClient = Server.svs.clients[i]; if (HostClient.active) { Server.DropClient(crash); } } // // clear structures // Server.sv.Clear(); for (int i = 0; i < Server.svs.clients.Length; i++) { Server.svs.clients[i].Clear(); } }