private void ComplexServer_AcceptByte(Communication.Core.Net.AppSession session, NetHandle handle, byte[] data) { // 接收字节数据, ShowTextInfo($"[{session.IpEndPoint}] [{handle}] {Communication.BasicFramework.SoftBasic.ByteToHexString(data)}"); // 也可以回发客户端信息,选择发送的session即可 }
private void ComplexServer_AcceptString(Communication.Core.Net.AppSession session, NetHandle handle, string data) { // 接收字符串 logNet.WriteInfo($"[{session.IpEndPoint}] [{handle}] {data}"); // 举个例子,当handle==1时,回发一串信息 // for example , when handle == 1. return text if (handle == 1) { complexServer.Send(session, handle, "This is test Text"); } }
private void SimplifyServer_ReceiveStringEvent(Communication.Core.Net.AppSession arg1, NetHandle handle, string msg) { if (handle == 1) { simplifyServer.SendMessage(arg1, handle, version.ToString()); string address = GetAddressByIp(arg1.IpAddress); lognet.WriteInfo($"{arg1.IpAddress.PadRight(15)} [{msg.PadRight(8)}] [{address}] Demo"); AddDict(address); } else if (handle == 2) { simplifyServer.SendMessage(arg1, random.Next(10000), "这是一条测试的数据:" + random.Next(10000).ToString()); } else if (handle == 100) { simplifyServer.SendMessage(arg1, handle, version2.ToString()); string address = GetAddressByIp(arg1.IpAddress); lognet.WriteInfo($"{arg1.IpAddress.PadRight(15)} [{msg.PadRight(8)}] [{address}] Controls"); AddDict(address); } else if (handle == 101) { simplifyServer.SendMessage(arg1, handle, version2.ToString()); string address = GetAddressByIp(arg1.IpAddress); lognet.WriteInfo($"{arg1.IpAddress.PadRight(15)} [{msg.PadRight(8)}] [{address}] Android Controls"); AddDict(address); } else if (handle == 200) { simplifyServer.SendMessage(arg1, handle, version.ToString()); string address = GetAddressByIp(arg1.IpAddress); lognet.WriteInfo($"{arg1.IpAddress.PadRight(15)} [{msg.PadRight(8)}] [{address}] Java"); AddDict(address); } else if (handle == 300) { simplifyServer.SendMessage(arg1, handle, version3.ToString()); string address = GetAddressByIp(arg1.IpAddress); lognet.WriteInfo($"{arg1.IpAddress.PadRight(15)} [{msg.PadRight(8)}] [{address}] Android"); AddDict(address); } else if (handle == 1000) { // 返回统计信息 simplifyServer.SendMessage(arg1, handle, GetData()); } else { simplifyServer.SendMessage(arg1, handle, msg); } }
private void ComplexClient_AcceptString(Communication.Core.Net.AppSession session, NetHandle handle, string data) { // 接收字符串 ShowTextInfo($"[{session.IpEndPoint}] [{handle}] {data}"); }
private void ComplexServer_ClientOnline(Communication.Core.Net.AppSession session) { // 上线触发 }
private void ComplexServer_ClientOffline(Communication.Core.Net.AppSession session, string reason) { // 下线触发 }