예제 #1
0
        private Dictionary <uint, UdpClientSession> dict = new Dictionary <uint, UdpClientSession>();  //conv -  UdpClientSession

        public UdpClientSession CreateSession(uint conv, IUdpMsgHandler _handler, Socket sendSocket, IPEndPoint remoteIEP, long heartBeatTime)
        {
            UdpClientSession session = new UdpClientSession(conv, sendSocket, remoteIEP, _handler, heartBeatTime);

            dict[session.GetConv()] = session;
            Log.InfoAf("[Udp] UdpClientSessionMgr  Conv={0} Add UdpClientSession RemoteIp ={1} RemotePort = {2}", conv, session.GetRemoteIp(), session.GetRemotePort());
            return(session);
        }
예제 #2
0
 public void DelSession(uint conv)
 {
     if (dict.ContainsKey(conv))
     {
         UdpClientSession session = dict[conv];
         Log.InfoAf("[Udp] UdpClientSessionMgr Del Conv ={0} UdpSession RemoteIp ={1} RemotePort = {2}", session.GetConv(), session.GetRemoteIp(), session.GetRemotePort());
         dict.Remove(conv);
     }
 }
예제 #3
0
        private void ProcessVerifyResMsg(IUdpEvent evt)
        {
            UdpClientReceiver receiver = evt.GetUdpReceiver() as UdpClientReceiver;

            if (receiver == null)
            {
                return;
            }

            UdpClientSessionMgr mgr     = receiver.GetUdpClientSessionMgr();
            UdpClientSession    session = mgr.FindSession(evt.GetConv());

            if (session != null)
            {
                Log.WarnAf("[Udp] UdpClientReceiver session exist conv = {0}", evt.GetConv());
                return;
            }
            receiver.GetUdpVerfiyResDele()(evt.GetConv(), receiver.GetSocket(), evt.GetIPEndPoint(), mgr);
        }
예제 #4
0
        private void ProcessClientKcpMsg(IUdpEvent evt)
        {
            UdpClientReceiver receiver = evt.GetUdpReceiver() as UdpClientReceiver;

            if (receiver == null)
            {
                return;
            }

            UdpClientSession session = receiver.GetUdpClientSessionMgr().FindSession(evt.GetConv());

            if (session == null)
            {
                Log.WarnAf("[Udp] UdpClientReceiver Conv = {0} Not Exist", evt.GetConv());
            }
            else if (evt.GetConv() == session.GetConv())
            {
                session.KcpInput(evt.GetMessage());
            }
        }