/// <summary> /// Receive a Chat Packet from the Client and set it as the TextInput for TextInputWaiters. /// </summary> public void _GetChatPacketBeforeLogin() { #region Receive a Chat Packet from the Client and set it as the TextInput for TextInputWaiters. //Console.WriteLine("NetObject.Client Ready"); while (ClientSocket.Connected) { //Console.WriteLine("NetObject.Client is waiting for data from its Client side socket."); //Console.WriteLine("NetObject.Client Listening..."); Logger.Console.WriteLine("Waiting"); Network.Packet InPacket = Network.Sockets.GetPacket(ClientSocket); Logger.Console.WriteLine("Received"); if (InPacket.Type == 32) { Network.Packets.Type32_ChatMessage ThisPacket = new Network.Packets.Type32_ChatMessage(InPacket); string EditMessage = ThisPacket.Message.Remove(0, 1); EditMessage = EditMessage.Remove(0, Parent.Username.Length); EditMessage = EditMessage.Remove(0, 1); //Console.WriteLine(EditMessage); Parent.TextInput = EditMessage; Logger.Console.WriteLine(Parent.TextInput); foreach (AutoResetEvent ThisEvent in Parent.TextWaiters.ToArray()) { ThisEvent.Set(); Parent.TextWaiters.Remove(ThisEvent); } return; } //Console.WriteLine("NetObject.Client Got Some Data."); if (InPacket.Type != 0) { PreviousPackets.Insert(0, InPacket); while (PreviousPackets.Count > 5) { PreviousPackets.RemoveAt(PreviousPackets.Count - 1); } Logger.Console.WriteLine("!=32"); //ProcessPacket(InPacket); //DONT DO THAT! WE DONT WANT A LOG IN TO HAPPEN ETC. } else { Logger.Console.WriteLine("CLOSE"); //The only time Socket Receive returns 0 is when a remote host disconnects, otherwise, it waits. Parent.Close(); } } Logger.Console.WriteLine("CLOSE2"); #endregion }
public static void StandardChatMessage(Server.NetObject ThisNetObj, Commands.CommandReader Cmd) { if (ThisNetObj.TextWaiters.Count > 0) { ThisNetObj.TextInput = Cmd._CmdComplete; foreach (AutoResetEvent ThisEvent in ThisNetObj.TextWaiters.ToArray()) { ThisEvent.Set(); ThisNetObj.TextWaiters.RemoveAll(x => x == ThisEvent); } return; } string output = FormatChatMessage(Cmd._CmdComplete, ThisNetObj); Server.AllClients.Except(Database.UserDB.Find("PHP bot")).SendMessage(output); //ThisNetObj.HostObject.SendMessage(output); Logger.Log.Chat(output); return; }