void ss_DataReceived(object sender, AsyncSocketUserTokenEventArgs e) { this.Invoke((MethodInvoker) delegate { if (richTextBox1.TextLength > 536870912) { richTextBox1.Clear(); } }); string data = e.ReceivedRawData.ToHexString(); this.Invoke((MethodInvoker) delegate { try { richTextBox1.AppendText(string.Format("----ClientId: {0}, ip: {1}, port: {2}, received: {3}", e.ConnectionId.ToString(), e.EndPoint.Address.ToString(), e.EndPoint.Port.ToString(), data)); richTextBox1.AppendText(Environment.NewLine); richTextBox1.ScrollToCaret(); } catch { } }); ss.Send(e.ConnectionId, e.ReceivedRawData); }
private static void sendLoginSuccess(AsyncSocketServer server, Guid ConnectionID) { StreamPackage <ResultMessage> result = new StreamPackage <ResultMessage>(); result.Command = Command.Login; result.Data.Ret = 0; server.Send(ConnectionID, result.DataBytes()); }
private void SendMsg(string msg) { if (msg.StartsWith("#LuaPush#")) { string luaName = msg.Replace("#LuaPush#", ""); G6HotFixUtil.SendLuaSciprtSource(luaName, false); } else { socketListener.Send(msg); } }
private static void sendFriendsMessage(AsyncSocketServer server, Guid ConnectionID) { StreamPackage <UsersMessage> usersMessage = new StreamPackage <UsersMessage>(); usersMessage.Command = Command.Friends; usersMessage.Data.List = new List <UserMessage>() { new UserMessage() { UID = 1, NickName = "11", Avatar = "111" }, new UserMessage() { UID = 2, NickName = "22", Avatar = "222" }, new UserMessage() { UID = 3, NickName = "33", Avatar = "333" } }; server.Send(ConnectionID, usersMessage.DataBytes()); }