Example #1
0
    static void Main(string[] args)
    {
        Console.WriteLine("输入ip:");
        string s = Console.ReadLine();

        if (s == "")
        {
            s = "127.0.0.1";
        }
        //Console.WriteLine("异步发送模式?(1:异步 其他:同步)");
        //if(Console.ReadLine() == "1") {
        //    UdpLibConfig.ServerSendAsync = true;
        //}
        Console.WriteLine("开始");
        IRQLog.AppLog = new IRQLog();
        IRQLog.AppLog.Start("output.csv");
        KCPServer server = new KCPServer(s, 10001);

        server.NewClientSession   += server_NewClientSession;
        server.CloseClientSession += server_CloseClientSession;
        server.RecvData           += server_RecvData;
        for (int i = 1; i < 10000; i++)
        {
            server.AddClientKey((uint)i, i);
        }
        server.StartReceive();
        while (true)
        {
            server.UpdateRepeatedly();
        }
    }
Example #2
0
    public KcpManager(int port)
    {
        Handlers = new KcpClientHandler();
        Handlers.AutoLoad();

        UdpLibConfig.MaxTimeNoData = new TimeSpan(0, 0, 5);

        server = new KCPServer(port);
        server.NewClientSession   += server_NewClientSession;
        server.CloseClientSession += server_CloseClientSession;
        server.RecvData           += server_RecvData;
        for (int i = 0; i < 10; i++)
        {
            server.AddClientKey((uint)i, i);
        }
        server.Start();
    }