/// <summary> /// User request some custom data, e.g. udp server port /// </summary> public void HRequestCustomData(TcpMessage Request) { CCommon.CustomData cData = (CCommon.CustomData)Request.State; if (!CustomData.ContainsKey(cData)) { return; } SendRequest(Users[Request.From].EndPoint, new RequestCustomData(Request.From, cData, CustomData[cData]).GetBytes()); }
/// <summary> /// Handle receiving custom data from server /// </summary> void ChatClient_OnCustomData(CCommon.CustomData customData, string Data) { switch (customData) { case CCommon.CustomData.RequestUdpPort: try { int port = Int32.Parse(Data); UdpServer = new IPEndPoint(Server.Address, port); } catch { } break; // Add new cases of CustomData } }