public void ListenForGame(BNetClient client) { // we should actually find server's public-interface and use that. var connectionInfo = bnet.protocol.game_master.ConnectInfo.CreateBuilder().SetToonId(client.CurrentToon.BnetEntityID).SetHost (Net.Game.Config.Instance.BindIP).SetPort(Net.Game.Config.Instance.Port).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); client.CallMethod(bnet.protocol.game_master.GameFactorySubscriber.Descriptor.FindMethodByName("NotifyGameFound"), builder.Build(), this.DynamicId); }
public void ListenForGame(BNetClient client) { var connectionInfo = bnet.protocol.game_master.ConnectInfo.CreateBuilder().SetToonId(client.CurrentToon.BnetEntityID).SetHost ("127.0.0.1").SetPort(Net.Game.Config.Instance.Port).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 AddMember(BNetClient client) { var identity = client.GetIdentity(false, false, true); var member = bnet.protocol.channel.Member.CreateBuilder() .SetIdentity(identity) .SetState(bnet.protocol.channel.MemberState.CreateBuilder() .AddRole(2) .SetPrivileges(0xFBFF) // 64511 .Build()) .Build(); // be carefult when editing the below rpc call, you may broke in game to error!! /raist. var builder = bnet.protocol.channel.AddNotification.CreateBuilder() .SetChannelState(this.State) .SetSelf(member); client.CallMethod(bnet.protocol.channel.ChannelSubscriber.Descriptor.FindMethodByName("NotifyAdd"), builder.Build(), this.DynamicId); this.Members.Add(client, member); }
public void NotifyChannelState(BNetClient 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); client.CallMethod(bnet.protocol.channel.ChannelSubscriber.Descriptor.FindMethodByName("NotifyUpdateChannelState"), builder.Build(), this.DynamicId); }
public void AddMember(BNetClient client) { if (HasUser(client)) { Logger.Warn("Attempted to add client {0} to channel when it was already a member of the channel", client.Connection.RemoteEndPoint.ToString()); return; } var identity = client.GetIdentity(false, false, true); var member = bnet.protocol.channel.Member.CreateBuilder() .SetIdentity(identity) .SetState(bnet.protocol.channel.MemberState.CreateBuilder() .AddRole(2) .SetPrivileges(0xFBFF) // 64511 .Build()) .Build(); // Be careful when editing the below RPC call, you may break in-game to error!! /raist var message = bnet.protocol.channel.AddNotification.CreateBuilder() .SetChannelState(this.State) .SetSelf(member) .AddMember(member) .Build(); // This needs to be here so that the foreach below will also send to the client that was just added this.Members.Add(client, member); var method = bnet.protocol.channel.ChannelSubscriber.Descriptor.FindMethodByName("NotifyAdd"); foreach (var pair in this.Members) { client.CallMethod(method, message, this.DynamicId); } client.CurrentChannel = this; }
public void Add(BNetClient 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.DynamicId); }
/*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(BNetClient 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.DynamicId); }