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); }
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 => { }); }
private void DoSet(Field field) { FieldOperation.Builder operation = FieldOperation.CreateBuilder(); Field.Builder returnField = Field.CreateBuilder().SetKey(field.Key); switch ((FieldKeyHelper.Program)field.Key.Program) { case FieldKeyHelper.Program.D3: if (field.Key.Group == 2 && field.Key.Field == 3) //CurrentActivity { returnField.SetValue(field.Value); Logger.Trace("{0} set CurrentActivity to {1}", this, field.Value.IntValue); } else if (field.Key.Group == 2 && field.Key.Field == 4) //Unknown bool { returnField.SetValue(field.Value); Logger.Trace("{0} set CurrentActivity to {1}", this, field.Value.BoolValue); } else if (field.Key.Group == 4 && field.Key.Field == 1) //PartyId { if (field.Value.HasMessageValue) //7727 Sends empty SET instead of a CLEAR -Egris { EntityId entityId = EntityId.ParseFrom(field.Value.MessageValue); Channel channel = ChannelManager.GetChannelByEntityId(entityId); if (LoggedInClient.CurrentChannel != channel) { LoggedInClient.CurrentChannel = channel; returnField.SetValue( Variant.CreateBuilder().SetMessageValue(channel.BnetEntityId.ToByteString()).Build()); Logger.Trace("{0} set channel to {1}", this, channel); } } else { if (LoggedInClient.CurrentChannel != null) { returnField.SetValue(Variant.CreateBuilder().SetMessageValue(ByteString.Empty).Build()); Logger.Warn("Emtpy-field: {0}, {1}, {2}", field.Key.Program, field.Key.Group, field.Key.Field); } } } else if (field.Key.Group == 4 && field.Key.Field == 2) //JoinPermission { //catch to stop Logger.Warn spam on client start and exit // should D3.4.2 int64 Current screen (0=in-menus, 1=in-menus, 3=in-menus); see ScreenStatus sent to ChannelService.UpdateChannelState call /raist if (ScreenStatus.Screen != field.Value.IntValue) { ScreenStatus = ScreenStatus.CreateBuilder().SetScreen((int)field.Value.IntValue).SetStatus(0).Build(); returnField.SetValue(Variant.CreateBuilder().SetIntValue(field.Value.IntValue).Build()); Logger.Trace("{0} set current screen to {1}.", this, field.Value.IntValue); } } else if (field.Key.Group == 4 && field.Key.Field == 3) //CallToArmsMessage { returnField.SetValue(field.Value); } else if (field.Key.Group == 4 && field.Key.Field == 4) //Party IsFull { returnField.SetValue(field.Value); } else if (field.Key.Group == 5 && field.Key.Field == 5) //Game IsPrivate { returnField.SetValue(field.Value); } else { Logger.Warn("GameAccount: Unknown set-field: {0}, {1}, {2} := {3}", field.Key.Program, field.Key.Group, field.Key.Field, field.Value); } break; case FieldKeyHelper.Program.BNet: if (field.Key.Group == 2 && field.Key.Field == 2) // SocialStatus { AwayStatus = (AwayStatusFlag)field.Value.IntValue; returnField.SetValue(Variant.CreateBuilder().SetIntValue((long)AwayStatus).Build()); Logger.Trace("{0} set AwayStatus to {1}.", this, AwayStatus); } else if (field.Key.Group == 2 && field.Key.Field == 8) { returnField.SetValue((field.Value)); } else if (field.Key.Group == 2 && field.Key.Field == 10) // AFK { returnField.SetValue(field.Value); Logger.Trace("{0} set AFK to {1}.", this, field.Value.BoolValue); } else { Logger.Warn("GameAccount: Unknown set-field: {0}, {1}, {2} := {3}", field.Key.Program, field.Key.Group, field.Key.Field, field.Value); } break; } //We only update subscribers on fields that actually change values. if (returnField.HasValue) { operation.SetField(returnField); UpdateSubscribers(Subscribers, new List <FieldOperation> { operation.Build() }); } }
public Field QueryField(FieldKey queryKey) { Field.Builder field = Field.CreateBuilder().SetKey(queryKey); switch ((FieldKeyHelper.Program)queryKey.Program) { case FieldKeyHelper.Program.D3: if (queryKey.Group == 2 && queryKey.Field == 1) // Banner configuration { field.SetValue( Variant.CreateBuilder().SetMessageValue(BannerConfigurationField.Value.ToByteString()).Build ()); } else if (queryKey.Group == 2 && queryKey.Field == 2) //Hero's EntityId { field.SetValue(Variant.CreateBuilder().SetMessageValue(LastPlayedHeroId.ToByteString()).Build()); } else if (queryKey.Group == 2 && queryKey.Field == 4) //Unknown Bool { field.SetValue(Variant.CreateBuilder().SetBoolValue(false).Build()); } else if (queryKey.Group == 3 && queryKey.Field == 1) // Hero's class (GbidClass) { field.SetValue(Variant.CreateBuilder().SetIntValue(CurrentToon.ClassID).Build()); } else if (queryKey.Group == 3 && queryKey.Field == 2) // Hero's current level { field.SetValue(Variant.CreateBuilder().SetIntValue(CurrentToon.Level).Build()); } else if (queryKey.Group == 3 && queryKey.Field == 3) // Hero's visible equipment { field.SetValue( Variant.CreateBuilder().SetMessageValue( CurrentToon.HeroVisualEquipmentField.Value.ToByteString()).Build()); } else if (queryKey.Group == 3 && queryKey.Field == 4) // Hero's flags (gender and such) { field.SetValue( Variant.CreateBuilder().SetIntValue((uint)(CurrentToon.Flags | ToonFlags.AllUnknowns)). Build()); } else if (queryKey.Group == 3 && queryKey.Field == 5) // Toon name { field.SetValue(Variant.CreateBuilder().SetStringValue(CurrentToon.Name).Build()); } else if (queryKey.Group == 3 && queryKey.Field == 6) { field.SetValue(Variant.CreateBuilder().SetIntValue(0).Build()); } else if (queryKey.Group == 3 && queryKey.Field == 7) { field.SetValue(Variant.CreateBuilder().SetIntValue(0).Build()); } else if (queryKey.Group == 4 && queryKey.Field == 1) // Channel ID if the client is online { if (LoggedInClient != null && LoggedInClient.CurrentChannel != null) { field.SetValue( Variant.CreateBuilder().SetMessageValue( LoggedInClient.CurrentChannel.D3EntityId.ToByteString()).Build()); } else { field.SetValue(Variant.CreateBuilder().Build()); } } else if (queryKey.Group == 4 && queryKey.Field == 2) // Current screen (all known values are just "in-menu"; also see ScreenStatuses sent in ChannelService.UpdateChannelState) { field.SetValue(Variant.CreateBuilder().SetIntValue(ScreenStatus.Screen).Build()); } else if (queryKey.Group == 4 && queryKey.Field == 4) //Unknown Bool { field.SetValue(Variant.CreateBuilder().SetBoolValue(false).Build()); } else { Logger.Warn("GameAccount Unknown query-key: {0}, {1}, {2}", queryKey.Program, queryKey.Group, queryKey.Field); } break; case FieldKeyHelper.Program.BNet: if (queryKey.Group == 2 && queryKey.Field == 1) //GameAccount Logged in { field.SetValue(Variant.CreateBuilder().SetBoolValue(GameAccountStatusField.Value).Build()); } else if (queryKey.Group == 2 && queryKey.Field == 2) // Away status { field.SetValue(Variant.CreateBuilder().SetIntValue((long)AwayStatus).Build()); } else if (queryKey.Group == 2 && queryKey.Field == 3) // Program - always D3 { field.SetValue(Variant.CreateBuilder().SetFourccValue("D3").Build()); } else if (queryKey.Group == 2 && queryKey.Field == 5) // BattleTag { field.SetValue(Variant.CreateBuilder().SetStringValue(Owner.BattleTag).Build()); } else if (queryKey.Group == 2 && queryKey.Field == 7) // DBAccount.EntityId { field.SetValue(Variant.CreateBuilder().SetEntityidValue(Owner.BnetEntityId).Build()); } else if (queryKey.Group == 2 && queryKey.Field == 10) // AFK { field.SetValue( Variant.CreateBuilder().SetBoolValue(AwayStatus != AwayStatusFlag.Available).Build()); } else { Logger.Warn("GameAccount Unknown query-key: {0}, {1}, {2}", queryKey.Program, queryKey.Group, queryKey.Field); } break; } return(field.HasValue ? field.Build() : null); }
public override void ListFactories(Google.ProtocolBuffers.IRpcController controller, ListFactoriesRequest request, Action <ListFactoriesResponse> done) { var response = ListFactoriesResponse.CreateBuilder(); var description = GameFactoryDescription.CreateBuilder(); description.SetId(14249086168335147635); description.AddAttribute(Attribute.CreateBuilder().SetName("min_players").SetValue(Variant.CreateBuilder().SetIntValue(2))); description.AddAttribute(Attribute.CreateBuilder().SetName("max_players").SetValue(Variant.CreateBuilder().SetIntValue(4))); description.AddAttribute(Attribute.CreateBuilder().SetName("num_teams").SetValue(Variant.CreateBuilder().SetIntValue(1))); description.AddAttribute(Attribute.CreateBuilder().SetName("version").SetValue(Variant.CreateBuilder().SetStringValue("0.3.0"))); var stats_bucket = GameStatsBucket.CreateBuilder(); stats_bucket.SetBucketMin(0) .SetBucketMax(4294967296) .SetWaitMilliseconds(1354) .SetGamesPerHour(0) .SetActiveGames(69) .SetActivePlayers(75) .SetFormingGames(0) .SetWaitingPlayers(0); description.AddStatsBucket(stats_bucket); response.AddDescription(description); response.SetTotalResults(1); done(response.Build()); }