示例#1
0
 static void Receiver_OnMessageReceived(object sender, MessageEventArgs e)
 {
     string message = e.message.Trim();
     int messageLength = e.message.Length;
     string receivedCommand = message.Substring(messageLength - 4);
     string movement = receivedCommand.Substring(1);
     char pistol = receivedCommand[0];
     Console.WriteLine("received command: " + movement + " from pistol " + pistol);
     switch (pistol)
     {
         case '1':
             greenCar.SendCommand(movement);
             break;
         case '2':
             redCar.SendCommand(movement);
             break;
         default:
             Console.WriteLine("unrecognized pistol: " + pistol);
             break;
     }
 }
示例#2
0
 static void Finish_OnMessageReceived(object sender, MessageEventArgs e)
 {
     string[] message = e.message.Split(' ');
     if (OnMessageReceivedFinish != null)
     {
         OnMessageReceivedFinish(new object(), new MessageEventArgs(message.Last()));
     }
 }
示例#3
0
 private static void Receiver_OnMessageReceived(object sender, MessageEventArgs e)
 {
     string message = e.message.Trim();
     int messageLength = e.message.Length;
     string receivedCommand = message.Substring(messageLength - 4);
     string movement = string.Join("",receivedCommand.Substring(1).Take(2).ToArray());
     char pistol = receivedCommand[0];
     Console.WriteLine("received command: " + movement + " from pistol " + pistol);
     switch (pistol)
     {
         case '1':
             MessageReceivedPistol1(movement);
             break;
         case '2':
             MessageReceivedPistol2(movement);
             break;
         default:
             Console.WriteLine("unrecognized pistol: " + pistol);
             break;
     }
 }
示例#4
0
 static void receiver_OnCommandSend(object sender, MessageEventArgs e)
 {
     Console.WriteLine(e.ToString());
 }
示例#5
0
 static void Finish_OnMessageReceived(object sender, MessageEventArgs e)
 {
     Console.WriteLine(e.message + " heeft gewonnen!");
 }