public static void DisconnectAll()
 {
     using (List <ServerState.ConnectionData> .Enumerator enumerator = ServerState.Connections.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             ServerState.ConnectionData connectionData = enumerator.Current;
             connectionData.rpc.Invoke("Disconnect", Array.Empty <object>());
         }
     }
 }
 public static void SaveAll()
 {
     using (List <ServerState.ConnectionData> .Enumerator enumerator = ServerState.Connections.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             ServerState.ConnectionData connectionData = enumerator.Current;
             connectionData.rpc.Invoke("CharacterUpdate", new object[]
             {
                 new ZPackage()
             });
         }
     }
 }
예제 #3
0
 private static void Game__Update()
 {
     // Are we the Server?
     if (ZNet.instance.IsServer())
     {
         float realtimeSinceStartup = Time.realtimeSinceStartup;
         using (List <ServerState.ConnectionData> .Enumerator enumerator = ServerState.Connections.GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 ServerState.ConnectionData connectionData = enumerator.Current;
                 if (realtimeSinceStartup - connectionData.LastTimeSaved >= (float)WorldofValheimServerSideCharacters.SaveInterval.Value)
                 {
                     connectionData.rpc.Invoke("CharacterUpdate", new object[]
                     {
                         new ZPackage()
                     });
                     connectionData.LastTimeSaved = realtimeSinceStartup;
                 }
             }
             return;
         }
     }
     // Ok we are the client! Can we DC?
     if (ServerState.ClientCanDC)
     {
         Debug.Log($"Deferred log m_quitting: {StandalonePatches.m_quitting} m_logging: {StandalonePatches.m_logging}");
         if (StandalonePatches.m_quitting)
         {
             Menu.instance.OnQuitYes();
         }
         else
         {
             Menu.instance.OnLogoutYes();
         }
         ServerState.Connections.Clear();
         ServerState.ClientCanDC      = false;
         StandalonePatches.m_quitting = false;
         StandalonePatches.m_logging  = false;
     }
 }