public void ListenForGame(Client client) { var connectionInfo = bnet.protocol.game_master.ConnectInfo.CreateBuilder().SetToonId(client.CurrentToon.BnetEntityID).SetHost ("127.0.0.1").SetPort((int)this.ID + 16000).SetToken(ByteString.CopyFrom(new byte[] {0x07, 0x34, 0x02, 0x60, 0x91, 0x93, 0x76, 0x46, 0x28, 0x84})) .AddAttribute(bnet.protocol.attribute.Attribute.CreateBuilder().SetName("SGameId").SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetIntValue(2014314530).Build())).Build(); var builder = bnet.protocol.game_master.GameFoundNotification.CreateBuilder(); builder.AddConnectInfo(connectionInfo); builder.SetRequestId(this.RequestID); builder.SetGameHandle(this.GameHandle); Logger.Trace("Game spawned: {0}:{1}", connectionInfo.Host, connectionInfo.Port); client.CallMethod(bnet.protocol.game_master.GameFactorySubscriber.Descriptor.FindMethodByName("NotifyGameFound"), builder.Build(), this.ID); }
public void Add(Client client) { var builder = bnet.protocol.channel.AddNotification.CreateBuilder(); var identity = bnet.protocol.Identity.CreateBuilder(); identity.SetAccountId(client.Account.BnetAccountID); identity.SetGameAccountId(client.Account.BnetGameAccountID); if (client.Account.Toons.Count > 0) identity.SetToonId(client.Account.Toons.First().Value.BnetEntityID); var state = bnet.protocol.channel.MemberState.CreateBuilder().AddRole(2).SetPrivileges(64511); var selfBuilder = bnet.protocol.channel.Member.CreateBuilder().SetIdentity(identity.Build()).SetState(state.Build()); var self = selfBuilder.Build(); builder.SetSelf(self); builder.AddMember(self); builder.SetChannelState(this.State); client.CallMethod(bnet.protocol.channel.ChannelSubscriber.Descriptor.FindMethodByName("NotifyAdd"), null, builder.Build(), null, r => { }); }
public void NotifyChannelState(Client client) { var field1 = bnet.protocol.presence.Field.CreateBuilder().SetKey( bnet.protocol.presence.FieldKey.CreateBuilder().SetProgram(16974).SetGroup(3).SetField(3).SetIndex(0) .Build()).SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetBoolValue(true).Build()).Build(); var field2 = bnet.protocol.presence.Field.CreateBuilder().SetKey( bnet.protocol.presence.FieldKey.CreateBuilder().SetProgram(16974).SetGroup(3).SetField(10).SetIndex(0) .Build()).SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetIntValue(1315530390868296).Build()).Build(); var field3 = bnet.protocol.presence.Field.CreateBuilder().SetKey( bnet.protocol.presence.FieldKey.CreateBuilder().SetProgram(16974).SetGroup(3).SetField(11).SetIndex(0) .Build()).SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetMessageValue( ByteString.CopyFrom(new byte[] { 0x9, 0x46, 0xee, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4, 0x11, 0xdd, 0xb4, 0x63, 0xe7, 0x82, 0x44, 0x68, 0x4e })).Build()).Build(); var fieldOperation1 = bnet.protocol.presence.FieldOperation.CreateBuilder().SetField(field1).Build(); var fieldOperation2 = bnet.protocol.presence.FieldOperation.CreateBuilder().SetField(field2).Build(); var fieldOperation3 = bnet.protocol.presence.FieldOperation.CreateBuilder().SetField(field3).Build(); var state = bnet.protocol.presence.ChannelState.CreateBuilder().SetEntityId(this.BnetEntityID).AddFieldOperation( fieldOperation1).AddFieldOperation(fieldOperation2).AddFieldOperation(fieldOperation3).Build(); var channelState = bnet.protocol.channel.ChannelState.CreateBuilder().SetExtension(bnet.protocol.presence.ChannelState.Presence, state); var builder = bnet.protocol.channel.UpdateChannelStateNotification.CreateBuilder().SetStateChange(channelState).Build(); client.CallMethod(bnet.protocol.channel.ChannelSubscriber.Descriptor.FindMethodByName("NotifyUpdateChannelState"), null, builder, null, r => { }); }
public void Add(Client client) { var identity = client.GetIdentity(false, false, true); var user = bnet.protocol.channel.Member.CreateBuilder() .SetIdentity(identity) .SetState(bnet.protocol.channel.MemberState.CreateBuilder() .AddRole(2) .SetPrivileges(0xFBFF) // 64511 .Build()) .Build(); this.Members.Add(user); var builder = bnet.protocol.channel.AddNotification.CreateBuilder() .SetChannelState(this.State) .SetSelf(user); // Cap includes the user that was added foreach (var m in this.Members) { builder.AddMember(m); } client.CallMethod(bnet.protocol.channel.ChannelSubscriber.Descriptor.FindMethodByName("NotifyAdd"), builder.Build(), this.ID); }
/*public void Close() { RemoveAllUsers(); } public void RemoveAllUsers() { // Need a way to iterate clients on the server to send a NotifyRemove // and then call RemoveUser on them this.Members.Clear(); }*/ public void RemoveUser(Client client) { var identity = client.GetIdentity(false, false, true); var builder = bnet.protocol.channel.RemoveNotification.CreateBuilder() .SetMemberId(identity.ToonId); this.Members.RemoveAll(m => identity == m.Identity); client.CurrentChannel = null; client.CallMethod(bnet.protocol.channel.ChannelSubscriber.Descriptor.FindMethodByName("NotifyRemove"), builder.Build(), this.ID); }