当前位置: 首页>>代码示例>>C#>>正文


C# MooNetClient.GetIdentity方法代码示例

本文整理汇总了C#中Mooege.Net.MooNet.MooNetClient.GetIdentity方法的典型用法代码示例。如果您正苦于以下问题:C# MooNetClient.GetIdentity方法的具体用法?C# MooNetClient.GetIdentity怎么用?C# MooNetClient.GetIdentity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mooege.Net.MooNet.MooNetClient的用法示例。


在下文中一共展示了MooNetClient.GetIdentity方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddMember

        public void AddMember(MooNetClient 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, true, false);

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

            //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.ToBuilder();
            if (this.Attributes.Count > 0)
                channelState.AddRangeAttribute(this.Attributes.Values);
            if (this.Invitations.Count > 0)
                channelState.AddRangeInvitation(this.Invitations.Values);
            // added member should recieve a NotifyAdd.
            var addNotification = bnet.protocol.channel.AddNotification.CreateBuilder()
                .SetChannelState(channelState.Build())
                .SetSelf(addedMember.BnetMember)
                .AddRangeMember(this.Members.Values.ToList().Select(member => member.BnetMember).ToList()).Build();

            client.MakeTargetedRPC(this, () =>
                bnet.protocol.channel.ChannelSubscriber.CreateStub(client).NotifyAdd(null, addNotification, callback => { }));

            //send bnet,2,7 target = addedmember.gameaccount
            //this always follows channel.AddNotification
            var fieldKey = FieldKeyHelper.Create(FieldKeyHelper.Program.D3, FieldKeyHelper.OriginatingClass.GameAccount, 7, 0);
            var field = bnet.protocol.presence.Field.CreateBuilder().SetKey(fieldKey);
            field.SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetStringValue(client.Account.BnetEntityId.Low.ToString() + "#1").Build());
            var operation = bnet.protocol.presence.FieldOperation.CreateBuilder().SetField(field.Build()).Build();
            var state = bnet.protocol.presence.ChannelState.CreateBuilder().SetEntityId(client.Account.CurrentGameAccount.BnetEntityId).AddFieldOperation(operation).Build();
            var channelStatePresense = bnet.protocol.channel.ChannelState.CreateBuilder().SetExtension(bnet.protocol.presence.ChannelState.Presence, state);
            var notification = bnet.protocol.channel.UpdateChannelStateNotification.CreateBuilder().SetStateChange(channelStatePresense).Build();
            client.MakeTargetedRPC(client.Account.CurrentGameAccount, () =>
                bnet.protocol.channel.ChannelSubscriber.CreateStub(client).NotifyUpdateChannelState(null, notification, callback => { }));


            if (this.IsGameChannel)
            {
                if (client.GameChannel != null)
                    Logger.Warn("Client {0} in game channel {1}, but joining game channel {2}.", client, client.GameChannel, this);
                client.GameChannel = this;
            }
            else
            {
                if (client.PartyChannel != null)
                    Logger.Warn("Client {0} in party channel {1}, but joining party channel {2}.", client, client.PartyChannel, this);
                client.PartyChannel = this;
            }

            client.CurrentChannel = this; // set clients current channel to one he just joined.

            if (this.Members.Count < 2) return;

            // other members should recieve a NotifyJoin.
            var joinNotification = bnet.protocol.channel.JoinNotification.CreateBuilder()
                .SetMember(addedMember.BnetMember).Build();

            foreach (var pair in this.Members.Where(pair => pair.Value != addedMember)) // only send this to previous members of the channel.
            {
                pair.Key.MakeTargetedRPC(this, () =>
                    bnet.protocol.channel.ChannelSubscriber.CreateStub(pair.Key).NotifyJoin(null, joinNotification, callback => { }));
            }
        }
开发者ID:God601,项目名称:mooege,代码行数:80,代码来源:Channel.cs

示例2: AddMember

        public void AddMember(MooNetClient 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;
        }
开发者ID:Rianon,项目名称:mooege,代码行数:47,代码来源:Channel.cs

示例3: AddMember

        public void AddMember(MooNetClient 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;

            // added member should recieve a NotifyAdd.
            var addNotification = bnet.protocol.channel.AddNotification.CreateBuilder()
                .SetChannelState(channelState)
                .SetSelf(addedMember.BnetMember)
                .AddRangeMember(this.Members.Values.ToList().Select(member => member.BnetMember).ToList()).Build();

            client.MakeTargetedRPC(this, () =>
                bnet.protocol.channel.ChannelSubscriber.CreateStub(client).NotifyAdd(null, addNotification, callback => { }));

            client.CurrentChannel = this; // set clients current channel to one he just joined.

            if (this.Members.Count < 2) return;

            // other members should recieve a NotifyJoin.
            var joinNotification = bnet.protocol.channel.JoinNotification.CreateBuilder()
                .SetMember(addedMember.BnetMember).Build();

            foreach (var pair in this.Members.Where(pair => pair.Value != addedMember)) // only send this to previous members of the channel.
            {
                pair.Key.MakeTargetedRPC(this, () =>
                    bnet.protocol.channel.ChannelSubscriber.CreateStub(pair.Key).NotifyJoin(null, joinNotification, callback => { }));
            }
        }
开发者ID:Velhenn,项目名称:mooege,代码行数:51,代码来源:Channel.cs


注:本文中的Mooege.Net.MooNet.MooNetClient.GetIdentity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。