• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# bnet类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中bnet的典型用法代码示例。如果您正苦于以下问题:C# bnet类的具体用法?C# bnet怎么用?C# bnet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



bnet类属于命名空间,在下文中一共展示了bnet类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Logon

        public override void Logon(Google.ProtocolBuffers.IRpcController controller, bnet.protocol.authentication.LogonRequest request, Action<bnet.protocol.authentication.LogonResponse> done)
        {
            Logger.Trace("LogonRequest(); Email={0}", request.Email);

            // we should be also checking here version, program, locale and similar stuff /raist.

            AuthManager.StartAuthentication(this.Client, request);

            var authenticationThread = new Thread(() =>
            {
                this.Client.AuthenticationCompleteSignal.WaitOne(); // wait the signal;

                if(this.Client.AuthenticationErrorCode != MooNetClient.AuthenticationErrorCodes.None)
                {
                    Logger.Info("Authentication failed for {0} because of invalid credentals.", request.Email);
                    done(bnet.protocol.authentication.LogonResponse.DefaultInstance);
                    return;
                }

                Logger.Info("User {0} authenticated successfuly.", request.Email);
                var builder = bnet.protocol.authentication.LogonResponse.
                    CreateBuilder()
                    .SetAccount(Client.Account.BnetAccountID)
                    .SetGameAccount(Client.Account.BnetGameAccountID);

                done(builder.Build());

                PlayerManager.PlayerConnected(this.Client);

            }) { IsBackground = true, CurrentCulture = CultureInfo.InvariantCulture }; ;

            authenticationThread.Start();
        }
开发者ID:ncoop23,项目名称:mooege,代码行数:33,代码来源:AuthenticationService.cs


示例2: SubscribeToFollowers

        public override void SubscribeToFollowers(Google.ProtocolBuffers.IRpcController controller, bnet.protocol.followers.SubscribeToFollowersRequest request, System.Action<bnet.protocol.followers.SubscribeToFollowersResponse> done)
        {
            Logger.Trace("Subscribe() {0}", this.Client);

            var builder = bnet.protocol.followers.SubscribeToFollowersResponse.CreateBuilder();
            done(builder.Build());
        }
开发者ID:ncoop23,项目名称:mooege,代码行数:7,代码来源:FollowersService.cs


示例3: SubscribeToUserManager

        public override void SubscribeToUserManager(Google.ProtocolBuffers.IRpcController controller, bnet.protocol.user_manager.SubscribeToUserManagerRequest request, System.Action<bnet.protocol.user_manager.SubscribeToUserManagerResponse> done)
        {
            Logger.Trace("Subscribe() {0}", this.Client);

            // temp hack: send him all online players on server where he should be normally get list of player he met in his last few games /raist.

            var builder = bnet.protocol.user_manager.SubscribeToUserManagerResponse.CreateBuilder();
            uint i = 0;
            foreach (var client in PlayerManager.OnlinePlayers)
            {
                if (client == this.Client) continue; // Don't add the requester to the list                
                if (client.Account.CurrentGameAccount.CurrentToon == null) continue;

                Logger.Debug("RecentPlayer => " + client.Account.CurrentGameAccount.CurrentToon);
                var recentPlayer = bnet.protocol.user_manager.RecentPlayer.CreateBuilder()
                    .SetEntity(client.Account.BnetEntityId)
                    .SetProgramId("D3")
                    .AddAttributes(bnet.protocol.attribute.Attribute.CreateBuilder()
                        .SetName("GameAccountEntityId")
                        .SetValue(bnet.protocol.attribute.Variant.CreateBuilder()
                            .SetMessageValue(client.Account.CurrentGameAccount.D3GameAccountId.ToByteString())
                            .Build())
                        .Build())
                    .SetId(i++)
                    .Build();
                builder.AddRecentPlayers(recentPlayer);
            }

            done(builder.Build());
        }
开发者ID:kiwi0530,项目名称:mooege,代码行数:30,代码来源:UserManagerService.cs


示例4: Unsubscribe

 public override void Unsubscribe(Google.ProtocolBuffers.IRpcController controller, bnet.protocol.presence.UnsubscribeRequest request, System.Action<bnet.protocol.NoData> done)
 {
     Logger.Trace("Unsubscribe()");
     //Logger.Debug("request:\n{0}", request.ToString());
     var builder = bnet.protocol.NoData.CreateBuilder();
     done(builder.Build());
 }
开发者ID:pvpmagebro,项目名称:d3sharp,代码行数:7,代码来源:PresenceService.cs


示例5: ParseCommand

        public void ParseCommand(bnet.protocol.notification.Notification request, MooNetClient client)
        {
            if (request.Type != "WHISPER") return;
            if (request.AttributeCount <= 0 || !request.AttributeList[0].HasValue)  return;

            CommandManager.TryParse(request.AttributeList[0].Value.StringValue, client, CommandManager.RespondOver.Whisper);
        }
开发者ID:ncoop23,项目名称:mooege,代码行数:7,代码来源:ServerCommandHandler.cs


示例6: SendInvitation

        public override void SendInvitation(IRpcController controller, bnet.protocol.invitation.SendInvitationRequest request, Action<bnet.protocol.NoData> done)
        {
            // somehow protobuf lib doesnt handle this extension, so we're using a workaround to get that channelinfo.
            var extensionBytes = request.UnknownFields.FieldDictionary[103].LengthDelimitedList[0].ToByteArray();
            var friendRequest = bnet.protocol.friends.SendInvitationRequest.ParseFrom(extensionBytes);

            if (friendRequest.TargetEmail.ToLower() == this.Client.Account.Email.ToLower()) return; // don't allow him to invite himself - and we should actually return an error!
                                                                                                    // also he shouldn't be allowed to invite his current friends - put that check too!. /raist
            var inviteee = AccountManager.GetAccountByEmail(friendRequest.TargetEmail);
            if (inviteee == null) return; // we need send an error response here /raist.

            Logger.Trace("{0} sent {1} friend invitation.", this.Client.Account, inviteee);

            var invitation = bnet.protocol.invitation.Invitation.CreateBuilder()
                .SetId(FriendManager.InvitationIdCounter++) // we may actually need to store invitation ids in database with the actual invitation there. /raist.                
                .SetInviterIdentity(this.Client.GetIdentity(true, false, false))
                .SetInviterName(this.Client.Account.Email) // we shoulde be instead using account owner's name here.
                .SetInviteeIdentity(bnet.protocol.Identity.CreateBuilder().SetAccountId(inviteee.BnetAccountID))
                .SetInviteeName(inviteee.Email) // again we should be instead using invitee's name.
                .SetInvitationMessage(request.InvitationMessage)
                .SetCreationTime(DateTime.Now.ToUnixTime())
                .SetExpirationTime(86400);

            // Response is bnet.protocol.NoData as of 7728. /raist.
            //var response = bnet.protocol.invitation.SendInvitationResponse.CreateBuilder()
            //    .SetInvitation(invitation.Clone());

            var response = bnet.protocol.NoData.CreateBuilder();
            done(response.Build());

            // notify the invitee on invitation.
            FriendManager.HandleInvitation(this.Client, invitation.Build());
        }
开发者ID:fasbat,项目名称:mooege,代码行数:33,代码来源:FriendsService.cs


示例7: SendNotification

        public override void SendNotification(Google.ProtocolBuffers.IRpcController controller, bnet.protocol.notification.Notification request, Action<bnet.protocol.NoData> done)
        {
            switch (request.GetNotificationType())
            {
                case NotificationTypeHelper.NotificationType.Whisper:

                    // NOTE: Real implementation doesn't even handle the situation where neither client knows about the other.
                    // Client requires prior knowledge of sender and target (and even then it cannot whisper by using the /whisper command).

                    Logger.Trace(string.Format("NotificationRequest.Whisper by {0} to {1}", this.Client.CurrentToon, ToonManager.GetToonByLowID(request.TargetId.Low)));

                    var targetAccount = ToonManager.GetOwnerAccountByToonLowId(request.TargetId.Low);
                    if (targetAccount.LoggedInClient == null) return;

                    if (targetAccount == this.Client.Account) // check if whisper targets the account itself.
                        CommandManager.TryParse(request.AttributeList[0].Value.StringValue, this.Client); // try parsing it as a command and respond it if so.
                    else
                    {
                        var notification = bnet.protocol.notification.Notification.CreateBuilder(request)
                            .SetSenderId(this.Client.CurrentToon.BnetEntityID)
                            .Build();

                        targetAccount.LoggedInClient.MakeRPC(() => 
                            bnet.protocol.notification.NotificationListener.CreateStub(targetAccount.LoggedInClient).OnNotificationReceived(controller, notification, callback => { }));
                    }
                    break;
                default:
                    Logger.Warn("Unhandled notification type: {0}", request.Type);
                    break;
            }

            var builder = bnet.protocol.NoData.CreateBuilder();
            done(builder.Build());
        }
开发者ID:wow4all,项目名称:mooege,代码行数:34,代码来源:NotificationService.cs


示例8: Unsubscribe

        public override void Unsubscribe(Google.ProtocolBuffers.IRpcController controller, bnet.protocol.presence.UnsubscribeRequest request, System.Action<bnet.protocol.NoData> done)
        {

            switch (request.EntityId.GetHighIdType())
            {
                case EntityIdHelper.HighIdType.AccountId:
                    var account = AccountManager.GetAccountByPersistentID(request.EntityId.Low);
                    // The client will probably make sure it doesn't unsubscribe to a null ID, but just to make sure..
                    if (account != null)
                    {
                        account.RemoveSubscriber(this.Client);
                        Logger.Trace("Unsubscribe() {0} {1}", this.Client, account);
                    }
                    break;
                case EntityIdHelper.HighIdType.GameAccountId:
                    var gameaccount = GameAccountManager.GetAccountByPersistentID(request.EntityId.Low);
                    if (gameaccount != null)
                    {
                        gameaccount.RemoveSubscriber(this.Client);
                        Logger.Trace("Unsubscribe() {0} {1}", this.Client, gameaccount);
                    }
                    break;
                default:
                    Logger.Warn("Recieved an unhandled Presence.Unsubscribe request with type {0} (0x{1})", request.EntityId.GetHighIdType(), request.EntityId.High.ToString("X16"));
                    break;
            }

            var builder = bnet.protocol.NoData.CreateBuilder();
            done(builder.Build());
        }
开发者ID:ReptileZ,项目名称:mooege,代码行数:30,代码来源:PresenceService.cs


示例9: SendInvitation

        public override void SendInvitation(IRpcController controller, bnet.protocol.invitation.SendInvitationRequest request, Action<SendInvitationResponse> done)
        {
            Logger.Trace("SendInvitation() Stub");

            //TODO: Set these to the corect values.
            const ulong accountHandle = 0x0000000000000000;
            const ulong gameAccountHandle = 0x0000000000000000;

            var invitation = bnet.protocol.invitation.Invitation.CreateBuilder()
                .SetCreationTime(DateTime.Now.ToUnixTime())
                .SetExpirationTime(request.ExpirationTime)
                .SetId(0)
                .SetInvitationMessage(request.InvitationMessage)
                .SetInviteeIdentity(bnet.protocol.Identity.CreateBuilder()
                                        .SetAccountId(bnet.protocol.EntityId.CreateBuilder().SetHigh(accountHandle).SetLow(0x1).Build()) //TODO: Change SetLow to an actual index in the database.
                                        .SetGameAccountId(bnet.protocol.EntityId.CreateBuilder().SetHigh(gameAccountHandle).SetLow(0x1).Build()) //TODO: Change SetLow to an actual index in the database.
                                        .Build())
                .SetInviteeName("FriendName") //TODO: Set this to the name retrieved from the database.
                .SetInviterIdentity(bnet.protocol.Identity.CreateBuilder()
                                        .SetAccountId(bnet.protocol.EntityId.CreateBuilder().SetHigh(accountHandle).SetLow(0x0).Build()) //TODO: Change SetLow to an actual index in the database.
                                        .SetGameAccountId(bnet.protocol.EntityId.CreateBuilder().SetHigh(gameAccountHandle).SetLow(0x0).Build()) //TODO: Change SetLow to an actual index in the database.
                                        .Build())
                .SetInviterName("YourName") //TODO: Set this to the name retrieved from the database.
                .Build();

            var builder = bnet.protocol.invitation.SendInvitationResponse.CreateBuilder().SetInvitation(invitation);
            done(builder.Build());
        }
开发者ID:pvpmagebro,项目名称:d3sharp,代码行数:28,代码来源:FriendsService.cs


示例10: Revoke

        public void Revoke(MooNetClient client, bnet.protocol.channel_invitation.RevokeInvitationRequest request)
        {
            if (!this._onGoingInvitations.ContainsKey(request.InvitationId)) return;
            var invitation = this._onGoingInvitations[request.InvitationId];

            //notify inviter about revoke
            var updateChannelNotification =
                bnet.protocol.channel.UpdateChannelStateNotification.CreateBuilder()
                .SetAgentId(bnet.protocol.EntityId.CreateBuilder().SetHigh(0).SetLow(0)) // caps have this set to high: 0 low: 0 /dustin
                .SetStateChange(bnet.protocol.channel.ChannelState.CreateBuilder()
                    .AddInvitation(invitation)
                    .SetReason((uint)InvitationRemoveReason.Revoked));

            this._onGoingInvitations.Remove(request.InvitationId);

            client.MakeTargetedRPC(client.CurrentChannel, () =>
                bnet.protocol.channel.ChannelSubscriber.CreateStub(client).NotifyUpdateChannelState(null, updateChannelNotification.Build(), callback => { }));

            //notify invitee about revoke
            var invitationRemoved =
                bnet.protocol.channel_invitation.InvitationRemovedNotification.CreateBuilder()
                .SetInvitation(invitation)
                .SetReason((uint)InvitationRemoveReason.Revoked);

            var invitee = ToonManager.GetToonByLowID(invitation.InviteeIdentity.ToonId.Low);
            invitee.Owner.LoggedInClient.MakeTargetedRPC(this, () =>
                bnet.protocol.channel_invitation.ChannelInvitationNotify.CreateStub(invitee.Owner.LoggedInClient).NotifyReceivedInvitationRemoved(null, invitationRemoved.Build(), callback => { }));
        }
开发者ID:wow4all,项目名称:mooege,代码行数:28,代码来源:ChannelInvitationManager.cs


示例11: Subscribe

        public override void Subscribe(Google.ProtocolBuffers.IRpcController controller, bnet.protocol.presence.SubscribeRequest request, System.Action<bnet.protocol.NoData> done)
        {
            switch (request.EntityId.GetHighIdType())
            {
                case EntityIdHelper.HighIdType.AccountId:
                    var account = AccountManager.GetAccountByPersistentID(request.EntityId.Low);
                    if (account != null)
                    {
                        Logger.Trace("Subscribe() {0} {1}", this.Client, account);
                        account.AddSubscriber(this.Client, request.ObjectId);
                    }
                    break;
                case EntityIdHelper.HighIdType.GameAccountId:
                    var gameaccount = GameAccountManager.GetAccountByPersistentID(request.EntityId.Low);
                    if (gameaccount != null)
                    {
                        Logger.Trace("Subscribe() {0} {1}", this.Client, gameaccount);
                        gameaccount.AddSubscriber(this.Client, request.ObjectId);
                    }
                    break;
                default:
                    Logger.Warn("Recieved an unhandled Presence.Subscribe request with type {0} (0x{1})", request.EntityId.GetHighIdType(), request.EntityId.High.ToString("X16"));
                    break;
            }

            var builder = bnet.protocol.NoData.CreateBuilder();
            done(builder.Build());
        }
开发者ID:ReptileZ,项目名称:mooege,代码行数:28,代码来源:PresenceService.cs


示例12: Subscribe

        public override void Subscribe(Google.ProtocolBuffers.IRpcController controller, bnet.protocol.presence.SubscribeRequest request, System.Action<bnet.protocol.NoData> done)
        {
            switch (request.EntityId.GetHighIdType())
            {
                case EntityIdHelper.HighIdType.AccountId:
                    var account = AccountManager.GetAccountByPersistentID(request.EntityId.Low);
                    if (account != null)
                    {
                        Logger.Trace("Subscribe() {0} {1}", this.Client, account);
                        account.AddSubscriber(this.Client, request.ObjectId);
                    }
                    break;
                case EntityIdHelper.HighIdType.ToonId:
                    var toon = ToonManager.GetToonByLowID(request.EntityId.Low);                    
                    if (toon != null) 
                    {
                        Logger.Trace("Subscribe() {0} {1}", this.Client, toon);
                        toon.AddSubscriber(this.Client, request.ObjectId); // The client will send us a Subscribe with ToonId of 0 the first time it tries to create a toon with a name that already exists. Let's handle that here.
                    }
                    break;
                default:
                    Logger.Warn("Recieved an unhandled Presence.Subscribe request with type {0}", request.EntityId.GetHighIdType());
                    break;
            }

            var builder = bnet.protocol.NoData.CreateBuilder();
            done(builder.Build());
        }
开发者ID:wow4all,项目名称:mooege,代码行数:28,代码来源:PresenceService.cs


示例13: SendNotification

        public override void SendNotification(Google.ProtocolBuffers.IRpcController controller, bnet.protocol.notification.Notification request, Action<bnet.protocol.NoData> done)
        {
            switch (request.GetNotificationType())
            {
                case NotificationTypeHelper.NotificationType.Whisper:
                    
                    // NOTE: Real implementation doesn't even handle the situation where neither client knows about the other.
                    // Client requires prior knowledge of sender and target (and even then it cannot whisper by using the /whisper command).

                    Logger.Trace(string.Format("NotificationRequest.Whisper by {0} to {1}", this.Client.CurrentToon, ToonManager.GetToonByLowID(request.TargetId.Low)));

                    var account = ToonManager.GetOwnerAccountByToonLowId(request.TargetId.Low);
                    if (account.LoggedInClient == null) return;

                    if (account is CommandHandlerAccount) // hackish way to enable server commands for players that are not in party.
                        CommandHandlerAccount.Instance.ParseCommand(request, this.Client);
                    else
                    {
                        var notification = bnet.protocol.notification.Notification.CreateBuilder(request)
                            .SetSenderId(this.Client.CurrentToon.BnetEntityID)
                            .Build();

                        account.LoggedInClient.MakeRPC(() => bnet.protocol.notification.NotificationListener.CreateStub(account.LoggedInClient).
                                      OnNotificationReceived(controller, notification, callback => { }));
                    }
                    break;
                default:
                    Logger.Warn("Unhandled notification type: {0}", request.Type);
                    break;
            }

            var builder = bnet.protocol.NoData.CreateBuilder();
            done(builder.Build());
        }
开发者ID:Velhenn,项目名称:mooege,代码行数:34,代码来源:NotificationService.cs


示例14: SendNotification

        public override void SendNotification(Google.ProtocolBuffers.IRpcController controller, bnet.protocol.notification.Notification request, Action<bnet.protocol.NoData> done)
        {
            Logger.Trace("SendNotification()");
            //Logger.Debug("notification:\n{0}", request.ToString());

            switch (request.GetNotificationType())
            {
                case NotificationTypeHelper.NotificationType.Whisper:
                    
                    // NOTE: Real implementation doesn't even handle the situation where neither client knows about the other.
                    // Client requires prior knowledge of sender and target (and even then it cannot whisper by using the /whisper command).

                    Logger.Trace(string.Format("NotificationRequest by {0} to {1}", this.Client.CurrentToon, ToonManager.GetToonByLowID(request.TargetId.Low)));

                    var account = ToonManager.GetOwnerAccountByToonLowId(request.TargetId.Low);
                    if (account.LoggedInClient == null) return;

                    var notification = bnet.protocol.notification.Notification.CreateBuilder(request)
                        .SetSenderId(this.Client.CurrentToon.BnetEntityID)
                        .Build();

                    var method = bnet.protocol.notification.NotificationListener.Descriptor.FindMethodByName("OnNotificationReceived");
                    account.LoggedInClient.CallMethod(method, notification);
                    break;
                default:
                    Logger.Warn("Unhandled notification type: {0}", request.Type);
                    break;
            }

            var builder = bnet.protocol.NoData.CreateBuilder();
            done(builder.Build());
        }
开发者ID:Sanchen,项目名称:mooege,代码行数:32,代码来源:NotificationService.cs


示例15: Unsubscribe

 public override void Unsubscribe(Google.ProtocolBuffers.IRpcController controller, bnet.protocol.presence.UnsubscribeRequest request, System.Action<bnet.protocol.NoData> done)
 {
     Logger.Trace("Unsubscribe()");
     Logger.Debug("request:\n{0}", request.ToString());
     
     switch (request.EntityId.GetHighIdType())
     {
         case EntityIdHelper.HighIdType.AccountId:
             var account = AccountManager.GetAccountByEntityID(request.EntityId);
             // The client will probably make sure it doesn't unsubscribe to a null ID, but just to make sure..
             if (account != null)
                 account.RemoveSubscriber((MooNetClient)this.Client);
             break;
         case EntityIdHelper.HighIdType.ToonId:
             var toon = ToonManager.GetToonByLowID(request.EntityId.Low);
             if (toon != null)
                 toon.RemoveSubscriber((MooNetClient)this.Client);
             break;
         default:
             Logger.Warn("Recieved an unhandled Presence.Unsubscribe request with type {0}", request.EntityId.GetHighIdType());
             break;
     }
     
     var builder = bnet.protocol.NoData.CreateBuilder();
     done(builder.Build());
 }
开发者ID:Rianon,项目名称:mooege,代码行数:26,代码来源:PresenceService.cs


示例16: Revoke

 public void Revoke(MooNetClient client, bnet.protocol.channel_invitation.RevokeInvitationRequest request)
 {
     if (!this._onGoingInvitations.ContainsKey(request.InvitationId)) return;
     this._onGoingInvitations.Remove(request.InvitationId);
     
     //TODO: We should be also notifying invitee somehow /raist
 }
开发者ID:Jonsevc,项目名称:mooege,代码行数:7,代码来源:ChannelInvitationManager.cs


示例17: InitAuthentication

        private static void InitAuthentication(MooNetClient client, bnet.protocol.authentication.LogonRequest request)
        {
            var account = AccountManager.GetAccountByEmail(request.Email); // check if account exists.
            
            if (account == null) // we should be returning an error to client /raist.
            {
                client.AuthenticationErrorCode = AuthenticationErrorCodes.NoGameAccount;
                client.AuthenticationCompleteSignal.Set();
                return;
            }

            var srp6a = new SRP6a(account); // create srp6 handler to process the authentication.
            OngoingAuthentications.Add(client, srp6a);

            // request client to load password.dll for authentication.
            var moduleLoadRequest = bnet.protocol.authentication.ModuleLoadRequest.CreateBuilder()
                .SetModuleHandle(bnet.protocol.ContentHandle.CreateBuilder()
                    .SetRegion(0x00005553) // us
                    .SetUsage(0x61757468) // auth - password.dll
                    .SetHash(ByteString.CopyFrom(ModuleHash)))
                .SetMessage(ByteString.CopyFrom(srp6a.LogonChallenge))
                .Build();

            client.MakeRPCWithListenerId(request.ListenerId, () =>
                bnet.protocol.authentication.AuthenticationClient.CreateStub(client).ModuleLoad(null, moduleLoadRequest, ModuleLoadResponse));
        }
开发者ID:fasbat,项目名称:mooege,代码行数:26,代码来源:AuthManager.cs


示例18: SubscribeToFriends

        public override void SubscribeToFriends(IRpcController controller, bnet.protocol.friends.SubscribeToFriendsRequest request, Action<bnet.protocol.friends.SubscribeToFriendsResponse> done)
        {
            Logger.Trace("Subscribe() {0}", this.Client);

            FriendManager.Instance.AddSubscriber(this.Client, request.ObjectId);

            var builder = bnet.protocol.friends.SubscribeToFriendsResponse.CreateBuilder()
                .SetMaxFriends(127)
                .SetMaxReceivedInvitations(127)
                .SetMaxSentInvitations(127)
                .AddRole(bnet.protocol.Role.CreateBuilder().SetId(1).SetName("battle_tag_friend").Build())
                .AddRole(bnet.protocol.Role.CreateBuilder().SetId(2).SetName("real_id_friend").Build());

            foreach (var friend in FriendManager.Friends[this.Client.Account.BnetEntityId.Low]) // send friends list.
            {
                builder.AddFriends(friend);
            }

            var invitations = new List<bnet.protocol.invitation.Invitation>();

            foreach (var invitation in FriendManager.OnGoingInvitations.Values)
            {
                if (invitation.InviteeIdentity.AccountId == this.Client.Account.BnetEntityId)
                {
                    invitations.Add(invitation);
                }
            }

            if (invitations.Count > 0)
                builder.AddRangeReceivedInvitations(invitations);

            done(builder.Build());
        }
开发者ID:ElCorpseMaker,项目名称:mooege,代码行数:33,代码来源:FriendsService.cs


示例19: Bind

        public override void Bind(Google.ProtocolBuffers.IRpcController controller, bnet.protocol.connection.BindRequest request, Action<bnet.protocol.connection.BindResponse> done)
        {
            Logger.Trace("Bind(): {0}", this.Client);

            var requestedServiceIDs = new List<uint>();

            foreach (var serviceHash in request.ImportedServiceHashList)
            {
                var serviceID = Service.GetByHash(serviceHash);
                requestedServiceIDs.Add(serviceID);

                Logger.Trace("[export] Hash: 0x{0} Id: 0x{1} Service: {2} ", serviceHash.ToString("X8"),serviceID.ToString("X2"), Service.GetByID(serviceID) != null ? Service.GetByID(serviceID).GetType().Name : "N/A");                
            }

            // read services supplied by client..
            foreach (var service in request.ExportedServiceList.Where(service => !Client.Services.ContainsValue(service.Id)))
            {
                if (Client.Services.ContainsKey(service.Hash)) continue;
                Client.Services.Add(service.Hash, service.Id);

                Logger.Trace(string.Format("[import] Hash: 0x{0} Id: 0x{1}", service.Hash.ToString("X8"), service.Id.ToString("X2")));
            }

            var builder = bnet.protocol.connection.BindResponse.CreateBuilder();
            foreach (var serviceId in requestedServiceIDs) builder.AddImportedServiceId(serviceId);
            
            done(builder.Build());
        }
开发者ID:God601,项目名称:mooege,代码行数:28,代码来源:ConnectionService.cs


示例20: ListFactories

        public override void ListFactories(IRpcController controller, bnet.protocol.game_master.ListFactoriesRequest request, Action<bnet.protocol.game_master.ListFactoriesResponse> done)
        {
            Logger.Trace("ListFactories() {0}", this.Client);

            var description = bnet.protocol.game_master.GameFactoryDescription.CreateBuilder().SetId(14249086168335147635);
            var attributes = new bnet.protocol.attribute.Attribute[4]
                {
                    bnet.protocol.attribute.Attribute.CreateBuilder().SetName("min_players").SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetIntValue(2)).Build(),
                    bnet.protocol.attribute.Attribute.CreateBuilder().SetName("max_players").SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetIntValue(4)).Build(),
                    bnet.protocol.attribute.Attribute.CreateBuilder().SetName("num_teams").SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetIntValue(1)).Build(),
                    bnet.protocol.attribute.Attribute.CreateBuilder().SetName("version").SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetStringValue("0.3.1")).Build() //This should be a static string so all versions are the same -Egris
                };

            description.AddRangeAttribute(attributes);
            description.AddStatsBucket(bnet.protocol.game_master.GameStatsBucket.CreateBuilder()
               .SetBucketMin(0)
               .SetBucketMax(4267296)
               .SetWaitMilliseconds(1354)
               .SetGamesPerHour(0)
               .SetActiveGames(69)
               .SetActivePlayers(75)
               .SetFormingGames(5)
               .SetWaitingPlayers(0).Build());

            var builder = bnet.protocol.game_master.ListFactoriesResponse.CreateBuilder().AddDescription(description).SetTotalResults(1);
            done(builder.Build());
        }
开发者ID:jujuman,项目名称:mooege,代码行数:27,代码来源:GameMasterService.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# boolean类代码示例发布时间:2022-05-24
下一篇:
C# ritter.javapi类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap