public void Send() { _client.Send(new ChatModel { Message = Message, UserName = UserName }); }
public static void Crypt(ChatClient client, string[] recieved) { string gameName = recieved[3].Substring(0, recieved[3].Length - 2); string serverKey = GenerateRandomString(17, StringType.AlphaNumeric); string clientKey = GenerateRandomString(17, StringType.AlphaNumeric); string sendingBuffer = string.Format(":s {0} * {1}{2}\r\n", 705, serverKey, clientKey); client.Send(sendingBuffer); }
static void Main() { Console.WriteLine("Application start...[ThreadID:{0}]", Thread.CurrentThread.ManagedThreadId); string app_identifier = "chat"; string server_ip = "127.0.0.1"; int server_port = 11515; int max_client = 100; ChatClient client = new ChatClient(); client.Init(app_identifier); ChatServer server = new ChatServer(); server.Init(app_identifier, server_port, max_client); while (true) { Console.Write("command> "); string line = Console.ReadLine(); if (line == "quit") { client.Close(); server.Stop(); break; } else if (line == "start server") { server.Start(); } else if (line == "connect") { client.Connect(server_ip, server_port); } else if (line.IndexOf("login") >= 0) { string[] token = line.Split(' '); if (token.Length >= 2) { client.Login(token[1]); } else { Console.WriteLine("Invalid command."); } } else if (line.IndexOf("logout") >= 0) { client.Logout(); } else if (line.IndexOf("send") >= 0) { string[] token = line.Split(' '); if (token.Length == 3) { client.Send(token[1], token[2]); } else { Console.WriteLine("Invalid command."); } } else { if (line.Length > 0 && client.IsLogin()) { client.SendToAll(line); } } } Console.WriteLine("Application is quitted!"); Console.Read(); }
private void Client1SendButton_Click(object sender, RoutedEventArgs e) { _chatClient1.Send("クライアント1: " + client1Message.Text + '\n'); client1Message.Clear(); }