Пример #1
0
        private void TheServer_ClientMessage(NamedPipeConnection <ContextContent, ContextContent> connection, ContextContent message)
        {
            this.Log("[SharedContext Server] Message received . " + connection.Name + " > Message: " + message.ToString() + " > " + DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fffff tt"));

            if (this.deserialisedContextContents.ToString() != message.ToString())
            {
                this.Log("[SharedContext Server] Using message as new content > " + DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fffff tt"));
                this.deserialisedContextContents = message;

                this.Log("[SharedContext Server] Sending message to all clients > " + DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fffff tt"));
                this.theServer.PushMessage(this.deserialisedContextContents);
            }
            else
            {
                this.Log("[SharedContext Server] No need to notify others. The context is the same as before. > " + DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fffff tt"));
            }
        }
Пример #2
0
        private void TheClient_ServerMessage(NamedPipeConnection <ContextContent, ContextContent> connection, ContextContent message)
        {
            if (!this.initialised)
            {
                this.Log("[SharedContext Client] " + (this._lock ? "Client" : "Trigger") + " initialised: " + connection.Name + " > " + DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fffff tt"));
                this.initialised = true;
                if (!this._lock)
                {
                    return;
                }
            }

            if (this.expectingLastMessage)
            {
                this.lastMessageReceived = true;
            }

            this.Log("[SharedContext " + (this._lock ? "Client" : "Trigger") + "] Message received . " + connection.Name + " > Message: " + message.ToString() + " > " + DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fffff tt"));
            this.deserialisedContextContents = message;

            if (EventHandler != null)
            {
                EventHandler.Invoke((object)connection, message);
            }
        }