Exemplo n.º 1
0
        public async Task <FriendListResponse> GetFriendList(string context)
        {
            var user = await this._userManager.GetUser(context);

            if (user == null)
            {
                return(new FriendListResponse {
                    StatusCode = StatusCode.NotFound, ErrorMessage = "User not found"
                });
            }

            var list     = user.Friends;
            var response = new FriendListResponse {
                StatusCode = StatusCode.Ok, FriendList = new List <UserResponse>()
            };

            foreach (var userId in list)
            {
                var tempUser = await this._userManager.GetUser(userId);

                if (tempUser != null)
                {
                    response.FriendList.Add(ConvertToUserResponse(tempUser));
                }
            }

            return(response);
        }
Exemplo n.º 2
0
 private void OnFriendList(object sender, FriendListResponse message)
 {
     //Debug.Log($"OnFriendList Update");
     if (message.Result == Result.Success)
     {
         FriendManager.Instance.FriendInit(message.Friends);
     }
 }
 private void OnFriendList(object sender, FriendListResponse message)
 {
     Debug.Log("OnFriendList");
     FriendManager.Instance.allFriends = message.Friends;
     if (this.OnFriendUpdate != null)
     {
         OnFriendUpdate.Invoke();
     }
 }
Exemplo n.º 4
0
        public int Call_FriendList(FriendListRequest request)
        {
            FriendListResponse response = new FriendListResponse();

            response.success = true;
            var player = CurrentSession.GetBindPlayer();

            response.pid         = player.Id;
            response.oilTimes    = player.FriendList.RecvTimes;
            response.maxOilTimes = 5;

            //FriendListResponse response = JsonConvert.DeserializeObject<FriendListResponse>("{\"oilTimes\":0,\"friends\":[],\"success\":true,\"maxOilTimes\":10}");
            CurrentSession.SendAsync(response);
            return(0);
        }
Exemplo n.º 5
0
        public async Task <IReadOnlyCollection <string> > GetFriends(string source)
        {
            if (!HasTicket)
            {
                throw new Exception();
            }

            FriendListResponse resp = null;

            using (var http = new HttpClient())
            {
                var msg = await RunQuery(http, Path.BookmarkList, new Dictionary <string, string> {
                    { "account", Ticket.Account },
                    { "ticket", Ticket.Ticket }
                });

                if (!msg.IsSuccessStatusCode)
                {
                    throw new Exception("HTTP request failed.");
                }

                resp = Response.Create <FriendListResponse>(await msg.Content.ReadAsStringAsync());
                if (!resp.Successful)
                {
                    throw new Exception("failed");
                }
            }

            var list = new List <string>();

            foreach (var character in resp.Friends.Where(f => f.Character.Equals(source, StringComparison.CurrentCultureIgnoreCase)))
            {
                list.Add(character.Friend);
            }
            return(list);
        }
Exemplo n.º 6
0
        public async Task Login(ObjectID characterId)
        {
            VerifyAuthenticated();

            var character = GrainFactory.GetGrain <ICharacter>(characterId);

            if (await character.Exists())
            {
                var entity = await character.GetCharacterEntity();

                // sanity checks
                if (entity.Account != AuthenticatedIdentity)
                {
                    GetLogger().Warn($"received login request from account {AuthenticatedIdentity} for character {entity.Name}, owned by {entity.Account}");
                    return;
                }
                if (entity.Shard != ShardName)
                {
                    GetLogger().Warn($"received login request from account {AuthenticatedIdentity} for character {entity.Name} which exists in shard {entity.Shard}, but this shard is {ShardName}");
                    return;
                }

                GetLogger().Info($"account {AuthenticatedIdentity} logs in as character {entity.Name}");

                ActiveCharacter = character;
                await ActiveCharacter.Login(this.GetPrimaryKey());

                var sendTasks = new LinkedList <Task>();

                var loginVerifyWorld = new LoginVerifyWorldRequest()
                {
                    MapId       = entity.MapId,
                    Position    = entity.Position,
                    Orientation = entity.Orientation,
                };
                sendTasks.AddLast(Send(loginVerifyWorld));

                var accountDataTimes = new AccountDataTimesRequest();
                sendTasks.AddLast(Send(accountDataTimes));

                var loginSetRestStart = new LoginSetRestStartRequest();
                sendTasks.AddLast(Send(loginSetRestStart));

                var updateBindPoint = new UpdateBindPointRequest()
                {
                    // TODO: implement bind point
                    Position = entity.Position,
                    MapId    = entity.MapId,
                    ZoneId   = entity.ZoneId,
                };
                sendTasks.AddLast(Send(updateBindPoint));

                var loginInitializeTutorial = new LoginTutorialRequest();
                sendTasks.AddLast(Send(loginInitializeTutorial));

                var loginInitializeSpells = new LoginInitializeSpellsRequest();
                sendTasks.AddLast(Send(loginInitializeSpells));

                var loginInitializeActionButtons = new LoginInitializeActionButtonsRequest();
                sendTasks.AddLast(Send(loginInitializeActionButtons));

                var timeService          = GrainFactory.GetGrain <ITimeService>(0);
                var loginSetTimeAndSpeed = new LoginSetTimeAndSpeedRequest()
                {
                    // TODO: configurize this?
                    GameSpeed  = 0.01666667f,
                    ServerTime = await timeService.GetNow(),
                };
                sendTasks.AddLast(Send(loginSetTimeAndSpeed));

                var friendList = new FriendListResponse();
                sendTasks.AddLast(Send(friendList));

                var ignoreList = new IgnoreListResponse();
                sendTasks.AddLast(Send(ignoreList));

                var initializeWorldState = new InitializeWorldStateRequest()
                {
                    MapId  = entity.MapId,
                    ZoneId = entity.ZoneId,
                };
                sendTasks.AddLast(Send(initializeWorldState));

                await Task.WhenAll(sendTasks);
            }
            else
            {
                GetLogger().Warn($"received login request from account {AuthenticatedIdentity} for non-existing character id {characterId}");
            }
        }