using FluorineFx.Messaging.Api.Service; using FluorineFx.Net; using System; using System.IO; using System.Threading; namespace TinyChatAdminSpam { internal class Client : IPendingServiceCallback { public const string MsgPath = "message.txt"; private static Random rand; private static string[] colors; private static int colorIndex; public NetConnection mNetConnection; private Thread thdHandler; public string roomName; public bool FlagDone; static Client() { Client.rand = new Random(); Client.colors = new string[11] { "#1965b6", "#32a5d9", "#7db257", "#a78901", "#9d5bb5", "#5c1a7a", "#c53332", "#821615", "#a08f23", "#487d21", "#c356a3" }; Client.colorIndex = 0; } public Client() { this.FlagDone = false; base.\u002Ector(); } public Client(string roomName) { this.FlagDone = false; base.\u002Ector(); this.mNetConnection = new NetConnection(); // ISSUE: method pointer this.mNetConnection.OnConnect += new ConnectHandler((object) this, __methodptr(OnConnect)); // ISSUE: method pointer this.mNetConnection.OnDisconnect += new DisconnectHandler((object) this, __methodptr(OnDisconnect)); this.roomName = roomName; } public void SetHandler(Thread thdHandler) { this.thdHandler = thdHandler; } private void OnConnect(object sender, EventArgs e) { if (this.mNetConnection.Connected) { Console.WriteLine("Connected."); Thread.Sleep(200); this.SetNick("TinyChatAdmin_" + this.GetRandomString(3)); Thread.Sleep(200); foreach (string message in File.ReadAllLines("message.txt")) { this.SendMessage(new Message(message)); Thread.Sleep(200); } } this.FlagDone = true; } private void OnDisconnect(object sender, EventArgs e) { Console.WriteLine("Disconnected."); this.thdHandler.Abort(); } private void SetNick(string name) { this.mNetConnection.Call("nick", (IPendingServiceCallback) this, new object[1] { (object) name }); } private void SendMessage(Message message) { ++Client.colorIndex; if (Client.colorIndex >= Client.colors.Length) Client.colorIndex = 0; this.mNetConnection.Call("privmsg", (IPendingServiceCallback) this, (object[]) new string[2] { message.Format(','), Client.colors[Client.colorIndex] + ",en" }); } private string GetRandomString(int length) { Thread.Sleep(25); Client.rand = new Random(DateTime.Now.Millisecond / new Random().Next(2, 5)); string str = ""; while (length-- > 0) str = str + (object) (char) Client.rand.Next(97, 122); return str; } public void ResultReceived(IPendingServiceCall call) { throw new NotImplementedException(); } } }