public async Task <ConnectResult> SendAccountAuthentication(ConnectData connectData)
        {
            var response = new SocketMessage();

            if (_socketManager.IsReconnecting)
            {
                response = await SendStandardMessage(
                    RouteProvider.AUTHENTICATION_RECONNECT,
                    RouteProvider.AuthenticationReconnect(connectData, _socketManager.ActiveCharacterId));
            }
            else
            {
                response = await SendStandardMessage(RouteProvider.LOGIN, RouteProvider.Login(connectData));
            }

            var loginData = SocketUtilities.ParseDataFromResponse <LoginDataDTO>(response.Response);

            ConnectResult connectResult = _socketManager.GetConnectResult();

            connectResult.IsConnected  = true;
            connectResult.AccessToken  = loginData?.AccessToken;
            connectResult.TW2AccountId = loginData?.PlayerId;

            _socketManager.ConnectData.AccessToken = loginData?.AccessToken;

            DataEvents.InvokeLoginDataAvailable(loginData);
            DataEvents.InvokeConnectionResult(connectResult);

            return(connectResult);
        }
        private async Task <bool> SendCharacterSelect(ICharacter selectedCharacter)
        {
            if (selectedCharacter == null)
            {
                return(false);
            }

            object dataObject = RouteProvider.SelectCharacter(selectedCharacter);

            var response = await SendStandardMessage(RouteProvider.SELECT_CHARACTER, dataObject);

            var charSelected = SocketUtilities.ParseDataFromResponse <CharacterSelectedDTO>(response.Response);

            _socketManager.ActiveCharacterId = charSelected.OwnerId;
            _socketManager.ActiveWorldId     = charSelected.WorldId;

            return(true);
        }
 /// <summary>
 /// A helper function which uses the default format for sending messages to the server
 /// </summary>
 /// <param name="sendType">The message type</param>
 public async Task <SocketMessage> SendStandardMessage(string sendType, object dataObject = null)
 {
     return(await SendMessageAsync(RouteProvider.GetDefaultSendMessage(sendType, dataObject)));
 }