예제 #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
 static public void SetWriter(UdpLog.Writer callback)
 {
     writer = callback;
 }