public void Run(string bootConf) { string bootConfigText = ConfigHelper.LoadFromFile(bootConf); JObject bootConfig = JObject.Parse(bootConfigText); m_tcpClient = new TCPClient(); m_tcpClient.Start(0, OnSessionError, OnReadPacketComplete, OnConnectComplete); string gatewayHost = bootConfig["Gateway"]["Host"].ToString(); string[] ipResult = gatewayHost.Split(':'); string gateIp = ipResult[0]; Int32 gatePort = Int32.Parse(ipResult[1]); m_tcpClient.Connect(gateIp, gatePort); m_isConnected = false; Console.WriteLine("Start Client... \n Please input message:"); Random rand = new Random(DateTime.Now.Millisecond); int contentSize = rand.Next(5, 15); char[] arr = { 'H', 'e', 'l', 'l', 'o' }; string content = ""; for (int i = 0; i < contentSize; i++) { content += arr[i % arr.Count()]; } m_hashCode = content.GetHashCode(); byte[] buffers = Encoding.ASCII.GetBytes(content); int increaceIndex = 0; while (true) { if (m_isConnected) { Session session = m_tcpClient.GetSessionBy(m_userData.SessionId); if (session != null && (increaceIndex % 5000 == 0)) { session.Write(buffers); } } increaceIndex++; m_tcpClient.Loop(); Thread.Sleep(1); } }