예제 #1
0
        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);
        }
예제 #2
0
 public bool HasUser(Client client)
 {
     return this.Members.Any(m => m.Identity == client.GetIdentity(false, false, true));
 }
예제 #3
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(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);
 }