Exemple #1
0
        public async Task Test(string ip, int port, int count, ushort startIndex, bool needNetty)
        {
            logger.Info($"begin test,count:${count},startIndex:{startIndex},needNetty:{needNetty}");

            var client = new FSClientBuilder()
                         .IceOptions(iceOptions =>
            {
                iceOptions.EnableDispatcher = false;
                iceOptions.PushObjects      = new List <Ice.Object>();
                iceOptions.PushObjects.Add(new PlayerPushI());
                iceOptions.PushObjects.Add(new ZonePushI());
            })
                         .NettyOptions(nettyOptions =>
            {
                nettyOptions.Port = 8007;
            })
                         .Build();

            //启动主线程
            //Thread thread = new Thread(new ThreadStart(async () =>
            //{
            //    do
            //    {
            //        client.Update();

            //        await Task.Delay(33);

            //     //   Thread.Sleep(33);

            //    } while (true);
            //}));
            //thread.Start();


            await client.StartAsync();

            for (ushort i = startIndex; i < startIndex + count; ++i)
            {
                var sessionId = "session" + i;
                var session   = await client.CreateSession(ip, port, sessionId);

                RunSession(session, i, 20, needNetty);
                playerCount++;
                await Task.Delay(10);
            }
            logger.Info("all session created:" + count);
        }
Exemple #2
0
        public async void Init(string ip, int port)
        {
            var client = new FSClientBuilder().IceOptions(iceOptions =>
            {
                iceOptions.EnableDispatcher = false;
                iceOptions.PushObjects      = new List <Ice.Object>();
                iceOptions.PushObjects.Add(new RoomPushI());
            }).NettyOptions(nettyOptions =>
            {
                nettyOptions.Port = 8007;
            }).Build();
            await client.StartAsync();

            var sessionId = "session" + 1;

            Session = await client.CreateSession(ip, port, sessionId);
        }