示例#1
0
        public async Task AcceptCommand()
        {
            var client = await _listener.AcceptTcpClientAsync();

            NetworkStream stream = client.GetStream();

            byte[] buffer = new byte[client.ReceiveBufferSize];

            int bytesRead = stream.Read(buffer, 0, client.ReceiveBufferSize);

            ReceivedCommands.Add(_serializer.Deserialize <Command>(buffer).Argument);
            stream.Write(buffer, 0, bytesRead);
            client.Close();
            _listener.Stop();
        }
示例#2
0
 public void SendData(byte[] data)
 {
     // saving the first byte is enough, because the StubMissileLauncher makes sure that the first byte contains the actual command
     ReceivedCommands.Add(data[0]);
 }
示例#3
0
        protected void AddCommand(Type senderType)
        {
            Argument.IsNotNull(() => senderType);

            ReceivedCommands.Add(string.Format("Type '{0}' has executed a command", senderType.Name));
        }