Beispiel #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Example: Simple");
            Console.WriteLine("Press [S] to start server");
            Console.WriteLine("Press [C] to start client");
            Console.Write("... ");

            UdpLog.SetWriter(Console.WriteLine);

            switch (Console.ReadKey(true).Key)
            {
            case ConsoleKey.S:
                Console.WriteLine("Server");
                Server();
                break;

            case ConsoleKey.C:
                Console.WriteLine("Client");
                Client();
                break;

            default:
                Main(args);
                break;
            }
        }
Beispiel #2
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;*/
            }
        }
Beispiel #3
0
        public UdpAdpaterConnection(int userdata)
        {
            UdpLog.SetWriter(new UdpLog.Writer(UdpLogWriter));

            UdpPlatform udpPlatform = new DotNetPlatform();

            socket = new UdpSocket(udpPlatform);
            CreateStreamChannel(1, "Default.Udp.StreamChannel", true, 9);
            socket.Start(UdpEndPoint.Any, UdpSocketMode.Client);
            totalTime = 0L;
            beginTime = 0L;
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            if (File.Exists("log.txt"))
            {
                File.Delete("log.txt");
            }

            var fs = File.AppendText("log.txt");

            sockets = new SocketObject[ClientCount + 1];
            Thread th = new Thread(ProcThread);

            UdpLog.SetWriter(s => { fs.WriteLine(s); });

            sockets[0] = new ServerObject();

            for (int i = 1; i < sockets.Length; ++i)
            {
                sockets[i] = new ClientObject();
            }

            start = DateTime.Now;
            th.Start();

            for (int i = 0; i < sockets.Length; ++i)
            {
                sockets[i].Start();
            }

            while (true)
            {
                Console.Clear();

                for (int i = 0; i < sockets[0].connections.Count; ++i)
                {
                    connectionStats(sockets[0].connections[i]);
                }


                Console.WriteLine("-");

                for (int i = 1; i < sockets.Length; ++i)
                {
                    if (sockets[i].connections.Count > 0)
                    {
                        connectionStats(sockets[i].connections[0]);
                    }
                }

                Thread.Sleep(100);
            }
        }
Beispiel #5
0
        static void Main(string[] args)
        {
            Console.BufferHeight = 5000;

            UdpLog.SetWriter(Console.WriteLine);

            serverThread = new Thread(Server);
            serverThread.IsBackground = true;
            serverThread.Name         = "server";
            serverThread.Start();

            clientThread = new Thread(Client);
            clientThread.IsBackground = true;
            clientThread.Name         = "client";
            clientThread.Start();

            Console.ReadLine();
        }
Beispiel #6
0
 void Awake()
 {
     UdpLog.SetWriter((s, lvl) => Debug.Log(s));
 }
Beispiel #7
0
 void Awake()
 {
     UdpLog.SetWriter((lvl, s) => Debug.Log(s));
 }
Beispiel #8
0
 void Awake()
 {
     UdpLog.SetWriter(s => Debug.Log(s));
 }