示例#1
0
 public void PaserCommand(string cmdstring)
 {
     cmdstring = cmdstring.Trim();
     string[] args = cmdstring.Split(new char[] { ' ' });
     if (args.Length > 0)
     {
         if (string.Compare(args[0], "exit", true) == 0)
         {
             LogoutMessage lgoutMsg = new LogoutMessage(myName);
             byte[]        buffer   = FormatterHelper.Serialize(lgoutMsg);
             client.Send(buffer, buffer.Length, hostPoint);
             // do clear something here
             Dispose();
             System.Environment.Exit(0);
         }
         else if (string.Compare(args[0], "send", true) == 0)
         {
             if (args.Length > 2)
             {
                 string toUserName = args[1];
                 string message    = "";
                 for (int i = 2; i < args.Length; i++)
                 {
                     if (args[i] == "")
                     {
                         message += " ";
                     }
                     else
                     {
                         message += args[i];
                     }
                 }
                 if (this.SendMessageTo(toUserName, message))
                 {
                     Console.WriteLine("Send OK!");
                 }
                 else
                 {
                     Console.WriteLine("Send to " + toUserName + " Failed!");
                 }
             }
         }
         else if (string.Compare(args[0], "getu", true) == 0)
         {
             ListUserMessage getUserMsg = new ListUserMessage(myName);
             byte[]          buffer     = FormatterHelper.Serialize(getUserMsg);
             client.Send(buffer, buffer.Length, hostPoint);
         }
         else
         {
             Console.WriteLine("Unknown command {0}", cmdstring);
         }
     }
 }
示例#2
0
 public void PaserCommand(string cmdstring)
 {
     cmdstring = cmdstring.Trim();
     string[] args = cmdstring.Split(new char[] { ' ' });
     if (args.Length > 0)
     {
         if (string.Compare(args[0], "exit", true) == 0)
         {
             LogoutMessage lgoutMsg = new LogoutMessage(myName);
             byte[] buffer = FormatterHelper.Serialize(lgoutMsg);
             client.Send(buffer, buffer.Length, hostPoint);
             // do clear something here
             Dispose();
             System.Environment.Exit(0);
         }
         else if (string.Compare(args[0], "send", true) == 0)
         {
             if (args.Length > 2)
             {
                 string toUserName = args[1];
                 string message = "";
                 for (int i = 2; i < args.Length; i++)
                 {
                     if (args[i] == "") message += " ";
                     else message += args[i];
                 }
                 if (this.SendMessageTo(toUserName, message))
                 {
                     Console.WriteLine("Send OK!");
                 }
                 else
                 {
                     Console.WriteLine("Send to " + toUserName + " Failed!");
                 }
             }
         }
         else if (string.Compare(args[0], "getu", true) == 0)
         {
             ListUserMessage getUserMsg = new ListUserMessage(myName);
             byte[] buffer = FormatterHelper.Serialize(getUserMsg);
             client.Send(buffer, buffer.Length, hostPoint);
         }
         else
         {
             Console.WriteLine("Unknown command {0}", cmdstring);
         }
     }
 }