示例#1
0
文件: Channel.cs 项目: orior/d3sharp
        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);
        }
示例#2
0
        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;
        }
示例#3
0
文件: Channel.cs 项目: nortex/d3sharp
        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);

            bool isOwner = client == this.Owner;
            var addedMember = new Member(identity,
                (isOwner) ? Member.Privilege.UnkCreator : Member.Privilege.UnkMember);

            if (this.Members.Count > 0)
            {
                addedMember.AddRoles(
                    (isOwner) ? Member.Role.PartyLeader : Member.Role.PartyMember,
                    Member.Role.ChannelMember);
            }
            else
            {
                addedMember.AddRole((isOwner) ? Member.Role.ChannelCreator : Member.Role.ChannelMember);
            }

            // This needs to be here so that the foreach below will also send to the client that was just added
            this.Members.Add(client, addedMember);

            // Cache the built state and member
            var channelState = this.State;
            var bnetMember = addedMember.BnetMember;

            var method = bnet.protocol.channel.ChannelSubscriber.Descriptor.FindMethodByName("NotifyAdd");
            foreach (var pair in this.Members)
            {
                var message = bnet.protocol.channel.AddNotification.CreateBuilder()
                    .SetChannelState(channelState)
                    // Set the Self property for each call on each client
                    // TODO: This may not be necessary here (this field is optional); check the caps
                    .SetSelf(pair.Value.BnetMember)
                    .AddMember(bnetMember)
                    .Build();
                //Logger.Warn("NotifyAdd:\n{0}", message.ToString());
                pair.Key.CallMethod(method, message, this.DynamicId);
            }
            client.CurrentChannel = this;
        }
示例#4
0
        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 addedMember = bnet.protocol.channel.Member.CreateBuilder()
                .SetIdentity(identity)
                .SetState(bnet.protocol.channel.MemberState.CreateBuilder()
                    .AddRole(2)
                    .SetPrivileges(0xFBFF) // 64511
                    .Build())
                .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, addedMember);
            
            var method = bnet.protocol.channel.ChannelSubscriber.Descriptor.FindMethodByName("NotifyAdd");
            foreach (var pair in this.Members)
            {
                var message = bnet.protocol.channel.AddNotification.CreateBuilder()
                    .SetChannelState(this.State)
                    // Here we have to set the self property for each call on each client
                    // TODO: This may not be necessary here (this field is optional); check the caps
                    .SetSelf(pair.Value)
                    .AddMember(addedMember)
                    .Build();
                pair.Key.CallMethod(method, message, this.DynamicId);
            }
            client.CurrentChannel = this;
        }
示例#5
0
        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);
        }
示例#6
0
 /*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);
 }
示例#7
0
 public bool HasUser(BNetClient client)
 {
     return this.Members.Any(m => m.Identity == client.GetIdentity(false, false, true));
 }