コード例 #1
0
        public void Setup()
        {
            RemoveEventListeners();

            ServerInitialized.Subscribe(data =>
            {
                DebugLog("Started server, clearing logs and removing event listeners.");
                Clear();
            });

            WelcomeClient.Subscribe(data =>
            {
                DebugLog($"Client {data.client_.guid} joined, replicating logs.");
                ReplicatePersonal(data.client_);
            });
            ClientDisconnected.Subscribe(data =>
            {
                DebugLog($"Client {data.networkPlayer_.guid} left, removing logs.");
                personalChatBuffers.Remove(GeneralUtilities.getUniquePlayerString(data.networkPlayer_));
                needsReplication.Remove(GeneralUtilities.getUniquePlayerString(data.networkPlayer_));
            });
            // fix remote logs
            SetServerChat.Subscribe(data =>
            {
                GeneralUtilities.logExceptions(() =>
                {
                    DebugLog($"Replicating remote log from SetServerChat...");
                    RemoveEventListeners();

                    AddRemoteLog(data.chatText_);
                });
            });
            ConnectedToServer.Subscribe(data =>
            {
                DebugLog("Connected to server, clearing logs and removing event listeners.");
                Clear();
                G.Sys.GameManager_.StartCoroutine(RemoveEventListenersCoroutine());
            });
            StartMode.Subscribe(data =>
            {
                DebugLog("Started mode from server, removing event listeners.");
                G.Sys.GameManager_.StartCoroutine(RemoveEventListenersCoroutine());
            });
        }