bool CreateClientPeer(UdpNetMessage udpNetMsg, IPEndPoint endPoint, out UdpClientPeer peer)
        {
            peer = default;
            bool result = false;

            if (!peerDict.ContainsKey(udpNetMsg.Conv))
            {
                peer = CosmosEntry.ReferencePoolManager.Spawn <UdpClientPeer>();
                peer.SetValue(this, onReceiveData, SendMessageAsync, udpNetMsg.Conv, endPoint);
                result = peerDict.TryAdd(udpNetMsg.Conv, peer);
                if (result)
                {
                    onConnected?.Invoke(udpNetMsg.Conv);
                    clientPeerRefreshHandler += peer.OnRefresh;
                }
            }
            return(result);
        }
 public UdpClientService() : base()
 {
     //构造传入0表示接收任意端口收发的数据
     peer = new UdpClientPeer();
     peer.SetValue(SendMessage, OnDeactive, 0, null);
 }