Beispiel #1
0
        private void ClientReceiveThreadProc()
        {
            while (true)
            {
                var receivedMessage = MindRpcFormatter.ReadMessage(this.clientStream);

                TivoProxyEventSource.Log.MessageFromClient(
                    this.serverEndPoint.ConnectionMode,
                    MindRpcFormatter.GetSchemaVersionFromHeader(receivedMessage.Item1),
                    MindRpcFormatter.GetRpcIdFromHeader(receivedMessage.Item1),
                    MindRpcFormatter.GetTypeFromHeader(receivedMessage.Item1),
                    receivedMessage.Item2);

                var onwardMessage = MindRpcFormatter.EncodeMessage(receivedMessage.Item1, receivedMessage.Item2);

                bool firstMessage = false;
                if (this.serverStream == null)
                {
                    firstMessage = true;

                    ConnectToServer().Wait();
                }

                this.serverStream.Write(onwardMessage, 0, onwardMessage.Length);

                if (firstMessage)
                {
                    Task.Factory.StartNew(this.ServerReceiveThreadProc, TaskCreationOptions.LongRunning);
                }
            }
        }
Beispiel #2
0
        private void ServerReceiveThreadProc()
        {
            while (true)
            {
                var receivedMessage = MindRpcFormatter.ReadMessage(this.serverStream);

                TivoProxyEventSource.Log.MessageFromServer(
                    this.serverEndPoint.ConnectionMode,
                    MindRpcFormatter.GetSchemaVersionFromHeader(receivedMessage.Item1),
                    MindRpcFormatter.GetRpcIdFromHeader(receivedMessage.Item1),
                    MindRpcFormatter.GetTypeFromHeader(receivedMessage.Item1),
                    receivedMessage.Item2);

                var onwardMessage = MindRpcFormatter.EncodeMessage(receivedMessage.Item1, receivedMessage.Item2);

                this.clientStream.WriteAsync(onwardMessage, 0, onwardMessage.Length);
            }
        }