public static void RemoveUnused <T>(this Array16 <T> arr, uint id) { ushort[] unusedItems = (ushort[])arr.GetType().GetField("m_unusedItems", AccessTools.all).GetValue(arr); FieldInfo unusedCountField = arr.GetType().GetField("m_unusedCount", AccessTools.all); uint unusedCount = (uint)unusedCountField.GetValue(arr); uint expectedPos = (uint)id - 1; // Special case, when array was modified (search for the id) if (unusedItems[expectedPos] != id) { bool found = false; for (uint num = 0; num <= unusedCount; num++) { if (unusedItems[num] == id) { expectedPos = num; found = true; break; } } if (!found) { // The arrays are no longer in sync CSM.Log("Error: Received id already in use. Please restart the multiplayer session!"); return; } } unusedItems[expectedPos] = unusedItems[--unusedCount]; unusedCountField.SetValue(arr, unusedCount); }
/// <summary> /// Stops the server /// </summary> public void StopServer() { // Update status and stop the server Status = ServerStatus.Stopped; NetServer.Stop(); CSM.Log("Stopped server"); }
private void button2_Click(object sender, EventArgs e) { CSC.ResetText(); CSM.ResetText(); DNTT.ResetText(); TT.ResetText(); TTCV.ResetText(); }
/// <summary> /// When we get a message from the server, we handle the message here /// and perform any necessary tasks. /// </summary> private void ListenerOnNetworkReceiveEvent(NetPeer peer, NetDataReader reader) { try { // The message type is the first byte, (255 message types) var messageType = reader.Data[0]; // Skip the first byte var message = reader.Data.Skip(1).ToArray(); // Switch between all the messages switch (messageType) { case CommandBase.ConnectionResultCommandId: // We only want this message while connecting if (Status != ClientStatus.Connecting) { break; } // Get the result var connectionResult = ConnectionResultCommand.Deserialize(message); if (connectionResult.Success) { // Log and set that we are connected. CSM.Log($"Successfully connected to server at {peer.EndPoint.Host}:{peer.EndPoint.Port}."); Status = ClientStatus.Connected; } else { CSM.Log($"Could not connect to server at {peer.EndPoint.Host}:{peer.EndPoint.Port}. Disconnecting... Error Message: {connectionResult.Reason}"); ConnectionMessage = $"Could not connect to server at {peer.EndPoint.Host}:{peer.EndPoint.Port}. Disconnecting... Error Message: {connectionResult.Reason}"; Disconnect(); } break; // Handle ping commands by returning the ping case CommandBase.PingCommandId: // Update the last server ping _lastServerPing = DateTime.UtcNow; // Send back a ping event peer.Send(ArrayHelpers.PrependByte(CommandBase.PingCommandId, new PingCommand().Serialize()), SendOptions.ReliableOrdered); break; case CommandBase.SimulationCommandID: var simulation = SimulationCommand.Deserialize(message); SimulationManager.instance.SimulationPaused = simulation.SimulationPaused; SimulationManager.instance.SelectedSimulationSpeed = simulation.SelectedSimulationSpeed; break; } } catch (Exception ex) { CSM.Log($"Received an error from {peer.EndPoint.Host}:{peer.EndPoint.Port}. Message: {ex.Message}"); } }
public void Init() { // Initialize the CSM with the context (in this case the critter whose states we're managing) _csm = new CSM <PageState, Pages>(this); //initiate the propertyEnum and all the behavior state _csm.Init <PageStatesList>(_propertyEnums); //pull saved infos }
/// <summary> /// Starts the server with the specified config options /// </summary> /// <param name="serverConfig">Server config information</param> /// <returns>If the server has started.</returns> public bool StartServer(ServerConfig serverConfig) { // If the server is already running, we will stop and start it again if (Status == ServerStatus.Running) { StopServer(); } // Set the config Config = serverConfig; // Let the user know that we are trying to start the server CSM.Log($"Attempting to start server on port {Config.Port}..."); // Attempt to start the server _netServer.DiscoveryEnabled = true; var result = _netServer.Start(Config.Port); // If the server has not started, tell the user and return false. if (!result) { CSM.Log("The server failed to start."); StopServer(); // Make sure the server is fully stopped return(false); } try { // This async stuff is nasty, but we have to target .net 3.5 (unless cities skylines upgrades to something higher). var nat = new NatDiscoverer(); var cts = new CancellationTokenSource(); cts.CancelAfter(5000); nat.DiscoverDeviceAsync(PortMapper.Upnp, cts).ContinueWith(task => task.Result.CreatePortMapAsync(new Mapping(Protocol.Udp, Config.Port, Config.Port, "Cities Skylines Multiplayer (UDP)"))).Wait(); } catch (Exception e) { CSM.Log("Failed to automatically open port. Manual Port Forwarding is required. " + e.Message); } // Update the status Status = ServerStatus.Running; // Set up processing thread _serverProcessingThread = new Thread(ProcessEvents); _serverProcessingThread.Start(); // Initialize host player _hostPlayer = new Player(Config.Username); MultiplayerManager.Instance.PlayerList.Add(_hostPlayer.Username); // Update the console to let the user know the server is running CSM.Log("The server has started."); return(true); }
/// <summary> /// Stops the server /// </summary> public void StopServer() { // Update status and stop the server Status = ServerStatus.Stopped; _netServer.Stop(); MultiplayerManager.Instance.PlayerList.Clear(); CSM.Log("Stopped server"); }
/// <summary> /// Attempt to disconnect from the server /// </summary> /// <returns></returns> public void Disconnect() { // Update status and stop client Status = ClientStatus.Disconnected; NetClient.Stop(); _pingTimer.Stop(); CSM.Log("Disconnected from server."); }
/// <summary> /// When we get a message from the server, we handle the message here /// and perform any necessary tasks. /// </summary> private void ListenerOnNetworkReceiveEvent(NetPeer peer, NetDataReader reader) { try { Command.ParseOnClient(reader.Data); } catch (Exception ex) { CSM.Log($"Encountered an error from {peer.EndPoint.Host}:{peer.EndPoint.Port} while reading command. Message: {ex.Message}"); } }
private void OnConnectButtonClick(UIComponent uiComponent, UIMouseEventParameter eventParam) { _connectionStatus.textColor = new Color32(255, 255, 0, 255); _connectionStatus.text = "Connecting..."; if (string.IsNullOrEmpty(_portField.text) || string.IsNullOrEmpty(_ipAddressField.text)) { _connectionStatus.textColor = new Color32(255, 0, 0, 255); _connectionStatus.text = "Invalid Port or IP"; return; } if (string.IsNullOrEmpty(_nameField.text)) { _connectionStatus.textColor = new Color32(255, 0, 0, 255); _connectionStatus.text = "Invalid Username"; return; } if (!int.TryParse(_portField.text, out var port)) { _connectionStatus.textColor = new Color32(255, 0, 0, 255); _connectionStatus.text = "Invalid Port"; return; } if (MultiplayerManager.Instance.CurrentRole == MultiplayerRole.Server) { _connectionStatus.textColor = new Color32(255, 0, 0, 255); _connectionStatus.text = "Already Running Server"; return; } // Try connect and get the result MultiplayerManager.Instance.ConnectToServer(_ipAddressField.text, port, _nameField.text, _passwordField.text, (success) => { Singleton <SimulationManager> .instance.m_ThreadingWrapper.QueueMainThread(() => { if (!success) { _connectionStatus.textColor = new Color32(255, 0, 0, 255); _connectionStatus.text = MultiplayerManager.Instance.CurrentClient.ConnectionMessage; CSM.Log(MultiplayerManager.Instance.CurrentClient.ConnectionMessage); } else { _connectionStatus.text = ""; CSM.Log("Connected!"); isVisible = false; } }); }); }
/// <summary> /// This method is used to extract the command type from an incoming message /// and return the matching handler object. /// </summary> /// <param name="msg">The incoming byte array including the command type byte.</param> /// <param name="handler">This returns the command handler object. May be null if the command was not found.</param> /// <param name="message">This returns the message byte array without the command type byte.</param> public static void Parse(byte[] msg, out CommandHandler handler, out byte[] message) { // The message type is the first byte, (255 message types) byte messageType = msg[0]; // Skip the first byte message = msg.Skip(1).ToArray(); if (!_handlerMapping.TryGetValue(messageType, out handler)) { CSM.Log($"Command {messageType} not found!"); return; } }
//------------------ public void AlCambiarValor() { Mision[] Iconos_Misiones = GameObject.FindObjectsOfType(typeof(Mision)) as Mision[]; foreach (Mision CSM in Iconos_Misiones) { if (CSM.LevelPromedio > (_NumeroFinalMisiones - 5) && CSM.LevelPromedio <= _NumeroFinalMisiones && !CSM.name.Contains("InformacionGuardada")) { bool activar = this.GetComponent <Toggle>().isOn; if (!CSM.SoldadoEnCamino) { CSM.Ocultar(activar); } } } }
/// <summary> /// Check if we are still conencted to the server /// </summary> private void OnPing(object sender, System.Timers.ElapsedEventArgs e) { // Client not connected, don't worry about this code if (Status == ClientStatus.Disconnected) { return; } // If we have not heard from the server in 5 seconds, it's probably gone // for now, we just disconnect. In the future we should try reconnecting and // displaying a UI. if (DateTime.UtcNow - _lastServerPing >= TimeSpan.FromSeconds(5)) { CSM.Log("Client lost connection with the server (time out, last ping > 5 seconds). Disconnecting..."); Disconnect(); } }
/// <summary> /// This method is used parse an incoming message on the server /// and execute the appropriate actions. /// </summary> /// <param name="msg">The incoming byte array including the command type byte.</param> /// <param name="player">The player object of the sending client. May be null if the sender is not known.</param> public static void ParseOnServer(byte[] msg, Player player) { Parse(msg, out CommandHandler handler, out byte[] message); if (handler == null) { return; } // Make sure we know about the connected client if (player == null) { CSM.Log($"Client tried to send packet {handler.GetType().Name} but never joined with a ConnectionRequestCommand packet. Ignoring..."); return; } handler.ParseOnServer(message, player); }
private void ListenerOnPeerDisconnectedEvent(NetPeer peer, DisconnectInfo disconnectInfo) { if (Status == ClientStatus.Connecting) { ConnectionMessage = "Failed to connect!"; } else { switch (disconnectInfo.Reason) { case DisconnectReason.Timeout: CSM.Log($"Timed out!"); break; case DisconnectReason.DisconnectPeerCalled: CSM.Log($"Disconnected!"); break; case DisconnectReason.RemoteConnectionClose: CSM.Log($"Server closed!"); break; default: CSM.Log($"Connection lost!"); break; } } // If Disconnect was already called, don't do it again if (Status == ClientStatus.Disconnected) { return; } if (Status == ClientStatus.Connected) { Disconnect(); } // In the case of ClientStatus.Connecting, this also ends the wait loop Status = ClientStatus.Disconnected; }
public override void HandleOnClient(ConnectionResultCommand command) { // We only want this message while connecting if (MultiplayerManager.Instance.CurrentClient.Status != ClientStatus.Connecting) { return; } // If we are allowed to connect if (command.Success) { // Log and set that we are connected. CSM.Log($"Successfully connected to server."); MultiplayerManager.Instance.CurrentClient.Status = ClientStatus.Connected; } else { CSM.Log($"Could not connect: {command.Reason}"); MultiplayerManager.Instance.CurrentClient.ConnectionMessage = $"Could not connect: {command.Reason}"; MultiplayerManager.Instance.CurrentClient.Disconnect(); } }
/// <summary> /// When we get a message from a client, we handle the message here /// and perform any necessary tasks. /// </summary> private void ListenerOnNetworkReceiveEvent(NetPeer peer, NetDataReader reader) { try { // Handle ConnectionRequest as special case if (reader.Data[0] == 0) { Command.Parse(reader.Data, out CommandHandler handler, out byte[] message); ConnectionRequestHandler requestHandler = (ConnectionRequestHandler)handler; requestHandler.HandleOnServer(message, peer); return; } this.ConnectedPlayers.TryGetValue(peer.ConnectId, out Player player); Command.ParseOnServer(reader.Data, player); } catch (Exception ex) { CSM.Log($"Encountered an error from {peer.EndPoint.Host}:{peer.EndPoint.Port} while reading command. Message: {ex.Message}"); } }
/// <summary> /// When we get a message from a client, we handle the message here /// and perform any necessary tasks. /// </summary> private void ListenerOnNetworkReceiveEvent(NetPeer peer, NetDataReader reader) { try { // The message type is the first byte, (255 message types) var messageType = reader.Data[0]; // Skip the first byte var message = reader.Data.Skip(1).ToArray(); // Switch between all the messages switch (messageType) { case CommandBase.ConnectionRequestCommandId: var connectionResult = Commands.ConnectionRequestCommand.Deserialize(message); CSM.Log($"Connection request from {peer.EndPoint.Host}:{peer.EndPoint.Port}. Version: {connectionResult.GameVersion}, ModCount: {connectionResult.ModCount}, ModVersion: {connectionResult.ModVersion}"); // TODO, check these values, but for now, just accept the request. SendToClient(peer, CommandBase.ConnectionResultCommandId, new ConnectionResultCommand { Success = true }); break; case CommandBase.SimulationCommandID: var simulation = SimulationCommand.Deserialize(message); SimulationManager.instance.SimulationPaused = simulation.SimulationPaused; SimulationManager.instance.SelectedSimulationSpeed = simulation.SelectedSimulationSpeed; break; } } catch (Exception ex) { CSM.Log($"Received an error from {peer.EndPoint.Host}:{peer.EndPoint.Port}. Message: {ex.Message}"); } }
/// <summary> /// When we get a message from a client, we handle the message here /// and perform any necessary tasks. /// </summary> private void ListenerOnNetworkReceiveEvent(NetPeer peer, NetDataReader reader) { try { // Handle ConnectionRequest as special case if (reader.Data[0] == 0) { Command.Parse(reader.Data, out CommandHandler handler, out byte[] message); ConnectionRequestHandler requestHandler = (ConnectionRequestHandler)handler; requestHandler.HandleOnServer(message, peer); return; } // Parse this message ConnectedPlayers.TryGetValue(peer.ConnectId, out Player player); Command.ParseOnServer(reader.Data, player); // Send this message to all other clients var peers = _netServer.GetPeers(); foreach (var client in peers) { // Don't send the message back to the client that sent it. if (client.ConnectId == peer.ConnectId) { continue; } // Send the message so the other client can stay in sync client.Send(reader.Data, SendOptions.ReliableOrdered); } } catch (Exception ex) { CSM.Log($"Encountered an error while reading command from {peer.EndPoint.Host}:{peer.EndPoint.Port}:"); CSM.Log(ex.ToString()); } }
private void ListenerOnPeerDisconnectedEvent(NetPeer peer, DisconnectInfo disconnectInfo) { if (!ConnectedPlayers.TryGetValue(peer.ConnectId, out Player player)) { return; } switch (disconnectInfo.Reason) { case DisconnectReason.RemoteConnectionClose: CSM.Log($"Player {player.Username} disconnected!"); break; case DisconnectReason.Timeout: CSM.Log($"Player {player.Username} timed out!"); break; default: CSM.Log($"Player {player.Username} lost connection!"); break; } HandlePlayerDisconnect(player); }
public void SRL(string FILE) { StreamWriter sw = new StreamWriter(string.Format("\\\\TLXSQL-DEV-01\\F$\\ETLS\\LogicMatter Flat Files\\SOLARWINDSHELPDESK\\incidents_{0:yyyy-MM-dd}.csv", DateTime.Now)); //StreamWriter sw = new StreamWriter(string.Format("Log\\incidents_{0:yyyy-MM-dd}.csv", DateTime.Now)); Console.WriteLine(string.Format("Fetching data -> incidents_{0:yyyy-MM-dd}.csv", DateTime.Now)); //sw.WriteLine("id,Number,State,Title,Priority,Category,Subcategory,Description,Assigned To,Requester,Created At,Created At (Timestamp),Site,Room #,Resolution"); sw.Write("id,Number,State,Title,Priority,Category,Subcategory,Description,Assigned_To,Assigned_Name,Assigned_Email,Requester,Created_by,Created At,Updated_At,Tags,Site,Department,Room,Printer_Issue,Phone_Issue,IT_Price_List,Student_Name,Grade_Level,Teacher_Advisor,Parent_Contact_Information,Referred_by,Abscences_Tardy,Academic_Concerns,Alleged_Bullying,Always_Tired,Anger_Aggression_Concerns,Appears_Anxious_Worried,Behavior_Concerns_Changes,Defiant,Destructive,"); sw.Write("Dishonesty,Easily_Distracted,Eating_Concerns,Emotional_Regulation,Family_Concerns_Changes,Fearful,Hurts_Self,Impulsive_Behaviors,Lack_of_Academic_Motivation,Loss_of_a_Loved_One_Grief,Peer_Mediation_Dispute_Resolution,Peer_Relationships_Friendships,Personal_Hygiene,Personal_Identity,Poor_Self_Image_Lacks_Confidence,Sadness,Social_Skills,Substance_Abuse,Thoughts_of_Suicide,Withdrawn,CPS_Report,Clarify_your_concerns,Have_you_informed_parent_guardian_about_your_concern,Date_Informed,SPED,504,Outside_Counseling,Unknown_none,"); sw.WriteLine("Resolution_Code,Resolution,CC,Resolved_At,Closed_At,Resolved_By,Resolved_By_Name"); Hashtable HT = new Hashtable(); XmlSerializer serializer = new XmlSerializer(typeof(SER.incidents)); using (FileStream fileStream = new FileStream("XML\\TOTAL.xml", FileMode.Open)) { SER.incidents result = (SER.incidents)serializer.Deserialize(fileStream); for (int x = 0; x < result.INC.Count; x++) { string[] CUSTOMS_NUM = new string[45]; for (int z = 0; z < CUSTOMS_NUM.Length; z++) { CUSTOMS_NUM[z] = string.Empty; } if (result.INC[x].custom_fields_values.Count != 0) { if (result.INC[x].custom_fields_values[0].CFV.Count != 0) { int y = 0; string[] CUSTOMS = { "Printer Issue", "Phone Issue", "Room #", "Student Name", "Grade Level", "Referred by", "Abscences/Tardy", "Academic Concerns", "Alleged Bullying", "Always Tired", "Anger/Aggression Concerns", "Appears Anxious/ Worried", "Behavior Concerns/Changes", "Defiant", "Destructive" }; foreach (string CSM in CUSTOMS) { if (result.INC[x].custom_fields_values[0].CFV[0].name.Equals(CSM)) { CUSTOMS_NUM[y] = result.INC[x].custom_fields_values[0].CFV[0].value; if (CSM.Equals("Student Name")) { for (int z = 1; z < 42; z++) { try { CUSTOMS_NUM[y + z] = result.INC[x].custom_fields_values[0].CFV[z].value.Replace("\"", "'"); } catch { } } } } y++; } } } /*sw.WriteLine(string.Format("\"{0}\",\"{1}\",\"{2}\",\"{3}\",\"{4}\",\"id: \"{5}\"~name: \"{6}\"~\"{7}\"~title: \"{8}\"~last_login: \"{9}\"~role: \"{10}\"~site: \"{11}\"~department: \"{12}\"~phone: \"{13}\"~mobile_phone: \"{14}\"~language: \"{15}\"~disabled: {16}\",\"{17}\",\"{18}\",\"{18}\",\"{19}\",\"{20}\",\"{21}\"", * result.INC[x].id, result.INC[x].number, result.INC[x].state, result.INC[x].CAT[0].name, result.INC[x].SUBCAT[0].name, * result.INC[x].ASSIGN[0].id, result.INC[x].ASSIGN[0].name, result.INC[x].ASSIGN[0].email, NORMALIZE(result.INC[x].ASSIGN[0].title), NORMALIZE(result.INC[x].ASSIGN[0].last_login).Replace("T", " "), NORMALIZE(result.INC[x].ASSIGN[0].ROLE[0].name), NORMALIZE(result.INC[x].ASSIGN[0].SITE[0].name), NORMALIZE(result.INC[x].ASSIGN[0].DEPARTMENT[0].name), NORMALIZE(result.INC[x].ASSIGN[0].phone), NORMALIZE(result.INC[x].ASSIGN[0].mobile_phone), NORMALIZE(result.INC[x].ASSIGN[0].SITE[0].language), NORMALIZE(result.INC[x].ASSIGN[0].disabled), * result.INC[x].REQUESTER[0].name, result.INC[x].created_at.Replace("T", " "), result.INC[x].SITE, ROOM, result.INC[x].updated_at.Replace("T", " "))); */ sw.Write(string.Format("\"{0}\",\"{1}\",\"{2}\",\"{3}\",\"{4}\",\"{5}\",\"{6}\",\"{7}\",\"{8}\",\"{9}\",\"{10}\",\"{11}\",\"{12}\",\"{13}\",\"{14}\",\"{15}\",\"{16}\",\"{17}\",\"{18}\",\"{19}\",\"{20}\",\"{21}\",", result.INC[x].id, result.INC[x].number, result.INC[x].state, result.INC[x].name, result.INC[x].priority, result.INC[x].CAT[0].name, result.INC[x].SUBCAT[0].name, result.INC[x].description.Replace("\"", "'"), result.INC[x].ASSIGN[0].id, result.INC[x].ASSIGN[0].name, result.INC[x].ASSIGN[0].email, result.INC[x].REQUESTER[0].name, result.INC[x].CREATEDBY[0].name, result.INC[x].created_at.Replace("T", " "), result.INC[x].updated_at.Replace("T", " "), result.INC[x].CAT[0].default_tags, result.INC[x].SITE, result.INC[x].DEPARTMENT[0].name, CUSTOMS_NUM[2], CUSTOMS_NUM[0], CUSTOMS_NUM[1], "" //, CUSTOMS_NUM[3], CUSTOMS_NUM[4], "", "" //CUSTOMS_NUM[5], CUSTOMS_NUM[6], CUSTOMS_NUM[7], CUSTOMS_NUM[8], CUSTOMS_NUM[9] )); for (int z = 3; z < 45; z++) { sw.Write(string.Format("\"{0}\",", CUSTOMS_NUM[z])); } string RESOLVE_AT = string.Empty, RESOLVED_BY = string.Empty, Closed_At = string.Empty, Resolved_By_Name = string.Empty; if (result.INC[x].state.Equals("Resolved")) { RESOLVE_AT = result.INC[x].updated_at.Replace("T", " "); RESOLVED_BY = result.INC[x].ASSIGN[0].name; Resolved_By_Name = result.INC[x].ASSIGN[0].name; } else if (result.INC[x].state.Equals("Closed")) { Closed_At = result.INC[x].updated_at.Replace("T", " "); } sw.WriteLine(string.Format("\"{0}\",\"{1}\",\"{2}\",\"{3}\",\"{4}\",\"{5}\",\"{6}\"", result.INC[x].resolution_code, result.INC[x].updated_at.Replace("T", " "), result.INC[x].CC[0].cc, RESOLVE_AT, Closed_At, RESOLVED_BY, Resolved_By_Name)); } } sw.Close(); }
/// <summary> /// Called whenever an error happens, we /// log this to the console for now. /// </summary> private void ListenerOnNetworkErrorEvent(NetEndPoint endpoint, int socketerrorcode) { CSM.Log($"Received an error from {endpoint.Host}:{endpoint.Port}. Code: {socketerrorcode}"); }
public void HandlePlayerConnect(Player player) { CSM.Log($"Player {player.Username} has connected!"); MultiplayerManager.Instance.PlayerList.Add(player.Username); Command.HandleClientConnect(player); }
/// <summary> /// Attempt to connect to a server /// </summary> /// <param name="clientConfig">Client config params</param> /// <returns>True if the client is connected to the server, false if not</returns> public bool Connect(ClientConfig clientConfig) { // if we are currently trying to connect, cancel // and try again. if (Status == ClientStatus.Connecting) { Disconnect(); } // The client is already connected so we need to // disconnect. if (Status == ClientStatus.Connected) { Disconnect(); } // Set the config _clientConfig = clientConfig; // Let the user know that we are trying to connect to a server CSM.Log($"Attempting to connect to server at {_clientConfig.HostAddress}:{_clientConfig.Port}..."); // Start the client, if client setup fails, return out and // tell the user var result = _netClient.Start(); if (!result) { ConnectionMessage = "The client failed to start."; Disconnect(); // make sure we are fully disconnected return(false); } // Try connect to server, update the status to say that // we are trying to connect. _netClient.Connect(_clientConfig.HostAddress, _clientConfig.Port); // Start processing networking Status = ClientStatus.Connecting; // Setup processing thread _clientProcessingThread = new Thread(ProcessEvents); _clientProcessingThread.Start(); // We need to wait in a loop for 30 seconds (waiting 500ms each time) // while we wait for a successful connection (Status = Connected) or a // failed connection (Status = Disconnected). var waitWatch = new Stopwatch(); waitWatch.Start(); while (waitWatch.Elapsed < TimeSpan.FromSeconds(30)) { // If we connect, exit the loop and return true if (Status == ClientStatus.Connected) { return(true); } // The client cannot connect for some reason, the ConnectionMessage // variable will contain why. if (Status == ClientStatus.Disconnected) { Disconnect(); // make sure we are fully disconnected return(false); } // Wait 500ms Thread.Sleep(500); } // We have timed out ConnectionMessage = "Could not connect to server, timed out."; // Did not connect Disconnect(); // make sure we are fully disconnected return(false); }
public override void HandleOnClient(ClientConnectCommand command) { CSM.Log($"Player {command.Username} has connected!"); MultiplayerManager.Instance.PlayerList.Add(command.Username); }