Пример #1
0
        public void Start(CClientNetworkCtrl clientNetworkCtrl)
        {
            if (server == null)
            {
                UdpLog.Writer writer = new UdpLog.Writer(DebugImplement);
                //(lvl, s) => Log.info("P2PClientNetWork",  s)
                UdpLog.SetWriter(writer);

                try
                {
                    server = UdpSocket.Create <UdpPlatformManaged, P2PSerializer>();
                }
                catch (Exception e) {
                    Log.info(e, "P2PClientNetWork Start#Exception happened");
                    //MonoBehaviour.print(e);
                }

                //sever and client.
                ConnectServer(clientNetworkCtrl);

                /*
                 * localPort = clientNetworkCtrl.LocalPort;
                 * UdpEndPoint serverPoint = new UdpEndPoint(UdpIPv4Address.Any, (ushort)localPort);
                 * server.Start(serverPoint);
                 * IPAddress ipaddr = IPAddress.Parse (clientNetworkCtrl.ServerIP);
                 * hostUser.ProxyServer = new IPEndPoint( ipaddr, clientNetworkCtrl.ServerPort );
                 *
                 * UdpIPv4Address address = UdpIPv4Address.Parse(clientNetworkCtrl.ServerIP);
                 * UdpEndPoint endp = new UdpEndPoint(address, (ushort)clientNetworkCtrl.ServerPort);
                 * server.Connect( endp );
                 *
                 * Log.info("P2PClientNetWork",  "P2PClientWork Start, UdpPort:" + localPort + " ServerIP:" + clientNetworkCtrl.ServerIP.ToString() + " ProxyServer address:" + endp.ToString());
                 * CtrlOwner = clientNetworkCtrl;*/
            }
        }
Пример #2
0
        /*
         * public uint UIN
         * {
         * get
         * {
         * return m_SocketInfo.m_Uin;
         * }
         * }*/


        private CNetWorkGlobal()
        {
            CNetStreamReader reader = new CNetStreamReader();

            reader.OnReceivePacketFinish = this.OnReceiveFullPacket;             //设置回调.

            m_Ctrl        = new CClientNetworkCtrl();
            m_Ctrl.Reader = reader;
            m_Ctrl.Writer = new CNetStreamWriter();

            m_SocketInfo = new CSocketInfo();
            //m_SocketInfo.m_Uin = 0;
            protoList = new Dictionary <int, DkRecProto>();
            isDebug   = false;
            m_isP2P   = false;
        }
Пример #3
0
        public void ConnectServer(CClientNetworkCtrl clientNetworkCtrl)
        {
            //sever and client.
            localPort = clientNetworkCtrl.LocalPort;
            UdpEndPoint serverPoint = new UdpEndPoint(UdpIPv4Address.Any, (ushort)localPort);

            server.Start(serverPoint);
            IPAddress ipaddr = IPAddress.Parse(clientNetworkCtrl.ServerIP);

            hostUser.ProxyServer = new IPEndPoint(ipaddr, clientNetworkCtrl.ServerPort);

            UdpIPv4Address address = UdpIPv4Address.Parse(clientNetworkCtrl.ServerIP);
            UdpEndPoint    endp    = new UdpEndPoint(address, (ushort)clientNetworkCtrl.ServerPort);

            server.Connect(endp);

            Log.info("UdpClientNetWork", "UdpClientNetWork Start, UdpPort:" + localPort + " ServerIP:" + clientNetworkCtrl.ServerIP.ToString() + " ProxyServer address:" + endp.ToString());
            CtrlOwner = clientNetworkCtrl;
        }
Пример #4
0
        /*
         * public void CreateP2PGroupProcess( uint groupid )
         * {
         *      if (m_Ctrl.UdpClient == null)
         *              return;
         *
         *      m_Ctrl.P2PClient.JoinP2PGroupReq (groupid);
         * }
         *
         * public void QuitP2PGroupProcess( uint groupid, uint uin )
         * {
         *      if (m_Ctrl.P2PClient == null)
         *              return;
         *
         *      m_Ctrl.P2PClient.QuitP2PGroupProcess (groupid, uin);
         * }*/

        public static string GetAdapterMAC()
        {
            return(CClientNetworkCtrl.GetAdapterMAC());
        }