Пример #1
0
        public override void ListFactories(IRpcController controller, ListFactoriesRequest request, Action <ListFactoriesResponse> done)
        {
            GameFactoryDescription.Builder description = GameFactoryDescription.CreateBuilder().SetId(0xc5beec600d8c6273);

            var atributes = new[]
            {
                Attribute.CreateBuilder().SetName("min_players").SetValue(Variant.CreateBuilder().SetIntValue(2)).Build(),
                Attribute.CreateBuilder().SetName("max_players").SetValue(Variant.CreateBuilder().SetIntValue(4)).Build(),
                Attribute.CreateBuilder().SetName("num_teams").SetValue(Variant.CreateBuilder().SetIntValue(1)).Build(),
                Attribute.CreateBuilder().SetName("version").SetValue(Variant.CreateBuilder().SetStringValue("0.3.0")).Build()
            };

            description.AddRangeAttribute(atributes);
            description.AddStatsBucket(GameStatsBucket.CreateBuilder()
                                       .SetBucketMin(0)
                                       .SetBucketMax(4294967296F)
                                       .SetWaitMilliseconds(1354)
                                       .SetGamesPerHour(0)
                                       .SetActiveGames(1)
                                       .SetActivePlayers(1)
                                       .SetFormingGames(0)
                                       .SetWaitingPlayers(0)
                                       .Build());

            ListFactoriesResponse response = ListFactoriesResponse.CreateBuilder().AddDescription(description).SetTotalResults(1).Build();

            done(response);
        }
Пример #2
0
        public override void FindGame(IRpcController controller, FindGameRequest request, Action <FindGameResponse> done)
        {
            FindGameResponse.Builder findGameResponse = FindGameResponse.CreateBuilder();
            findGameResponse.SetRequestId(12526585062881647236);

            done(findGameResponse.Build());

            client.ListenerId = request.ObjectId;

            GameFoundNotification.Builder gameFoundNotification = GameFoundNotification.CreateBuilder();

            GameHandle.Builder gameHandle = GameHandle.CreateBuilder();
            gameHandle.SetFactoryId(request.FactoryId);
            gameHandle.SetGameId(EntityId.CreateBuilder().SetHigh(433661094641971304).SetLow(11017467167309309688).Build());

            ConnectInfo.Builder connectInfo = ConnectInfo.CreateBuilder();
            connectInfo.SetToonId(new EntityId.Builder
            {
                High = HighId.Toon,
                Low  = 2
            }.Build());
            connectInfo.SetHost("127.0.0.1");
            connectInfo.SetPort(6665);
            connectInfo.SetToken(ByteString.CopyFrom(new byte[] { 0x07, 0x34, 0x02, 0x60, 0x91, 0x93, 0x76, 0x46, 0x28, 0x84 }));
            connectInfo.AddAttribute(Attribute
                                     .CreateBuilder()
                                     .SetName("SGameId")
                                     .SetValue(Variant
                                               .CreateBuilder()
                                               .SetIntValue(2014314530)
                                               .Build())
                                     .Build());

            gameFoundNotification.SetRequestId(12526585062881647236);
            gameFoundNotification.SetGameHandle(gameHandle.Build());
            gameFoundNotification.AddConnectInfo(connectInfo.Build());

            GameFactorySubscriber.CreateStub(client).NotifyGameFound(controller, gameFoundNotification.Build(), r => { });
        }