Exemplo n.º 1
0
        /// <summary>
        /// 从指定的<see cref="BinaryReader"/>中读取消息。
        /// </summary>
        /// <param name="reader">读取器</param>
        /// <returns>消息</returns>
        public static ConsoleMessage Read(BinaryReader reader)
        {
            reader.ReadInt32();
            var message = new ConsoleMessage
            {
                Command = readString(reader),
                Content = readString(reader),
            };

            return(message);
        }
Exemplo n.º 2
0
        private static void sendToRemoteConsole(string text)
        {
            if (mClient == null || !mClient.Connected)
            {
                return;
            }

            using (var stream = mClient.GetStream())
            {
                var writer = new BinaryWriter(stream);
                var msg    = new ConsoleMessage
                {
                    Command = "Log",
                    Content = text,
                };
                var bytes = msg.Serialize();
                writer.Write(bytes);
            }
        }