コード例 #1
0
ファイル: MainWindow.xaml.cs プロジェクト: petrind/SRTesis2
 static void ReadMessage(ClientInfo ci, uint code, byte[] buf, int len)
 {
     Console.WriteLine("Message, code " + code.ToString("X8") + ", content:");
     byte[] ba = new byte[len];
     Array.Copy(buf, ba, len);
     Console.WriteLine("  " + ByteBuilder.FormatParameter(new Parameter(ba, ParameterType.Byte)));
     ci.SendMessage(code, buf, (byte)0, len);
 }
コード例 #2
0
ファイル: MainWindow.xaml.cs プロジェクト: petrind/SRTesis2
            static void ReadMessage(ClientInfo ci, uint code, byte[] buf, int len)
            {
                if (code == ClientInfo.CommandCode)
                {
                    Console.WriteLine("Message length, code " + code.ToString("X8") + ", content:"+buf.ToString());

                    messageCommand(System.Text.Encoding.UTF8.GetString(buf, 0, len));
                    ci.SendMessage(ClientInfo.StringCode, Encoding.UTF8.GetBytes(code.ToString("X8")+" success"));
                
                }
                else if (code == ClientInfo.VoiceCode)
                {
                    Console.WriteLine("Message length, code " + code.ToString("X8") + ", content:" + buf.ToString());

                    messageVoice(System.Text.Encoding.UTF8.GetString(buf, 0, len));
                    ci.SendMessage(ClientInfo.VoiceCode, Encoding.UTF8.GetBytes(code.ToString("X8") + " success"));
                }
                else if (code == ClientInfo.moveToCode)
                {
                    Console.WriteLine("Message length, code " + code.ToString("X8") + ", content:" + buf.ToString());

                    string[] value = System.Text.Encoding.UTF8.GetString(buf, 0, len).Split(',');
                    naoMotion.moveTo(float.Parse(value[0]), float.Parse(value[1]), float.Parse(value[2]));
                    ci.SendMessage(ClientInfo.VoiceCode, Encoding.UTF8.GetBytes(code.ToString("X8") + " success"));
                }
                else if (code == ClientInfo.movePeonCode)
                {
                    Console.WriteLine("Message length, code " + code.ToString("X8") + ", content:" + buf.ToString());

                    string[] value = System.Text.Encoding.UTF8.GetString(buf, 0, len).Split(',');
                    naoMotion.movePeon(float.Parse(value[0]), float.Parse(value[1]), float.Parse(value[2]), float.Parse(value[3]), float.Parse(value[4]), float.Parse(value[5]));
                    ci.SendMessage(ClientInfo.movePeonCode, Encoding.UTF8.GetBytes(code.ToString("X8") + " success"));
                }
            }