コード例 #1
0
ファイル: RPGPeer.cs プロジェクト: yaomaoxing/qiusuo
 /// <summary>
 /// 客户端连接过来进行操作
 /// </summary>
 /// <param name="initRequest"></param>
 public RPGPeer(InitRequest initRequest) : base(initRequest)
 {
     PeerGuid   = Guid.NewGuid();
     _udpDriver = new UdpDriver(this);
     RoomId     = -1;
     lock (PeerDict)
     {
         PeerDict.Add(PeerGuid.ToString(), this);
     }
     SendParams.ChannelId = 0;//设置udp协议的通道id
     Log.InfoFormat("客户端连接:PeerGuid => {0},ConnectionId => {1},RemoteIP => {2}:{3}", PeerGuid, initRequest.ConnectionId, initRequest.RemoteIP, initRequest.RemotePort);
     PrintPeerState();
 }
コード例 #2
0
ファイル: RPGPeer.cs プロジェクト: yaomaoxing/qiusuo
 /// <summary>
 /// 客户端断线处理
 /// </summary>
 /// <param name="reasonCode"></param>
 /// <param name="reasonDetail"></param>
 protected override void OnDisconnect(DisconnectReason reasonCode, string reasonDetail)
 {
     if (!Enum.IsDefined(typeof(DisconnectReason), reasonCode))
     {
         throw new ArgumentOutOfRangeException(nameof(reasonCode));
     }
     Log.Info("peer disconnect, PeerGuid:" + PeerGuid + ", reasonCode:" + reasonCode);
     lock (PeerDict)
     {
         PeerDict.Remove(PeerGuid.ToString());
     }
     _udpDriver.OnDisconnect();
     Dispose();
 }