Exemplo n.º 1
0
        public void TestBoxing(string base58)
        {
            var account = new AccountId(base58);
            var copy    = (object)account;

            Assert.Equal(account.ToString(), copy.ToString());
        }
Exemplo n.º 2
0
        public void Death(string killer, Entity entity = null, WmapTile tile = null, bool rekt = false)
        {
            if (_client.State == ProtocolState.Disconnected || _dead)
            {
                return;
            }

            if (tile != null && tile.Spawned)
            {
                rekt = true;
            }

            _dead = true;

            if (Rekted(rekt))
            {
                return;
            }
            if (Arena(killer))
            {
                return;
            }
            if (NonPermaKillEnemy(entity, killer))
            {
                return;
            }
            if (TestWorld(killer))
            {
                return;
            }
            if (Resurrection())
            {
                return;
            }

            SaveToCharacter();
            Manager.Database.Death(Manager.Resources.GameData, _client.Account,
                                   _client.Character, FameCounter.Stats, killer);

            GenerateGravestone();
            AnnounceDeath(killer);

            _client.SendPacket(new Death()
            {
                AccountId = AccountId.ToString(),
                CharId    = _client.Character.CharId,
                KilledBy  = killer,
                ZombieId  = -1
            });

            Owner.Timers.Add(new WorldTimer(1000, (w, t) =>
            {
                if (_client.Player != this)
                {
                    return;
                }

                _client.Disconnect();
            }));
        }
Exemplo n.º 3
0
        public IAsyncResult BeginRemovePresenceSubscription(AccountId userId, AsyncCallback callback)
        {
            AssertLoggedIn();
            AsyncNoResult ar = new AsyncNoResult(callback);

            if (!_presenceSubscriptions.ContainsKey((userId)))
            {
                ar.SetCompletedSynchronously();
                return(ar);
            }
            var request = new vx_req_account_buddy_delete_t();

            request.account_handle = _accountHandle;
            request.buddy_uri      = userId.ToString();
            VxClient.Instance.BeginIssueRequest(request, result =>
            {
                try
                {
                    VxClient.Instance.EndIssueRequest(result);
                    _presenceSubscriptions.Remove(userId);
                    ar.SetComplete();
                }
                catch (Exception e)
                {
                    VivoxDebug.Instance.VxExceptionMessage($"{request.GetType().Name} failed: {e}");
                    ar.SetComplete(e);
                    if (VivoxDebug.Instance.throwInternalExcepetions)
                    {
                        throw;
                    }
                    return;
                }
            });
            return(ar);
        }
Exemplo n.º 4
0
        public void TestCopy(string base58)
        {
            var account = new AccountId(base58);
            var copy    = account;

            Assert.Equal(account.ToString(), copy.ToString());
        }
Exemplo n.º 5
0
        public static void GetSessionOwnedRoomsService(AccountId accountId, System.Action <XmlDocument> getRoomServiceFinishedCallback)
        {
            mLogger.DebugFormat("GetSessionOwnedRoomsService called accountId={0}", accountId);
            WebServiceRequest getRoomList = new WebServiceRequest(StateServerConfig.WebServicesBaseUrl, "Rooms", "GetRooms");

            getRoomList.AddParam(kAccountId, accountId.ToString());
            getRoomList.GetWebResponseAsync(getRoomServiceFinishedCallback);
        }
Exemplo n.º 6
0
        public static void DisableRoomService(AccountId accountId, RoomId roomId, System.Action <XmlDocument> disableRoomServiceCallback)
        {
            WebServiceRequest disableRoomInDatabaseService = new WebServiceRequest(StateServerConfig.WebServicesBaseUrl, "Rooms", "DisableRoom");

            disableRoomInDatabaseService.AddParam(kRoomId, roomId.ToString());
            disableRoomInDatabaseService.AddParam(kAccountId, accountId.ToString());
            disableRoomInDatabaseService.GetWebResponseAsync(disableRoomServiceCallback);
        }
Exemplo n.º 7
0
 public void WriteJson(Utf8JsonWriter writer)
 {
     writer.WriteStartObject();
     writer.WriteString("currency", CurrencyCode.ToString());
     writer.WriteString("issuer", Issuer.ToString());
     writer.WriteString("value", Value.ToString());
     writer.WriteEndObject();
 }
Exemplo n.º 8
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("AccountId=" + AccountId.ToString());
            sb.AppendLine("Enabled=" + Enabled.ToString());

            return(sb.ToString());
        }
Exemplo n.º 9
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("AccessToken=" + AccessToken.ToString());
            sb.AppendLine("AccountId=" + AccountId.ToString());
            sb.AppendLine("AccountInfo=" + AccountInfo.ToString());

            return(sb.ToString());
        }
Exemplo n.º 10
0
 public override string ToString()
 {
     return("\n----------- ServerAccount ---------------" +
            "\nFacebookId:\t" + mFbAccountId.ToString() +
            "\nAccountId:\t" + mAccountId.ToString() +
            "\nNickname:\t" + mNickname +
            "\nFirstname:\t" + mFirstName +
            "\nLastname:\t" + mLastName +
            "\nUserProperties:\n" + mUserProperties.ToString() +
            "\n-----------------------------------------\n");
 }
Exemplo n.º 11
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("AccountId=" + AccountId.ToString());
            sb.AppendLine("Password="******"Server=" + Server.ToString());
            sb.AppendLine("UserName=" + UserName.ToString());

            return(sb.ToString());
        }
Exemplo n.º 12
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("AccountId=" + AccountId.ToString());
            sb.AppendLine("Directory=" + Directory.ToString());
            sb.AppendLine("Enabled=" + Enabled.ToString());
            sb.AppendLine("EnsureUniqueFilenames=" + EnsureUniqueFilenames.ToString());

            return(sb.ToString());
        }
Exemplo n.º 13
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("AccountId=" + AccountId.ToString());
            sb.AppendLine("CreateShareLink=" + CreateShareLink.ToString());
            sb.AppendLine("Enabled=" + Enabled.ToString());
            sb.AppendLine("EnsureUniqueFilenames=" + EnsureUniqueFilenames.ToString());
            sb.AppendLine("SharedFolder=" + SharedFolder.ToString());

            return(sb.ToString());
        }
Exemplo n.º 14
0
        public static void CreateNewRoomService(AccountId accountId, string roomName, PrivacyLevel privacyLevel, System.Action <XmlDocument> createRoomFinishedCallback)
        {
            mLogger.DebugFormat("CreateNewRoomService called accountId={0} roomName={1} privacyLevel={2}", accountId, roomName, privacyLevel);
            WebServiceRequest createRoomService = new WebServiceRequest(StateServerConfig.WebServicesBaseUrl, "Rooms", "CreateRoom");

            createRoomService.Encrypted = true;
            createRoomService.AddParam(kAccountId, accountId.ToString());
            createRoomService.AddParam(kRoomName, roomName);
            createRoomService.AddParam(kPrivacyLevel, ((int)privacyLevel).ToString());
            createRoomService.AddParam(kDefaultRoomId, "1");
            createRoomService.GetWebResponseAsync(createRoomFinishedCallback);
        }
Exemplo n.º 15
0
        public static void GetSessionOwnedRoomsWithPrivacyService(AccountId accountId, PrivacyLevel privacyLevel, System.Action <XmlDocument> getRoomServiceFinishedCallback)
        {
            mLogger.DebugFormat("GetSessionOwnedRoomsWithPrivacyService called accountId={0} privacyLevel={1}", accountId, privacyLevel);
            WebServiceRequest getRoomList = new WebServiceRequest(StateServerConfig.WebServicesBaseUrl, "Rooms", "GetRooms");

            getRoomList.AddParam(kAccountId, accountId.ToString());
            if (privacyLevel != PrivacyLevel.Default)
            {
                getRoomList.AddParam(kPrivacyLevel, ((uint)privacyLevel).ToString());
            }
            getRoomList.GetWebResponseAsync(getRoomServiceFinishedCallback);
        }
Exemplo n.º 16
0
        protected async Task <JObject[]> GetAccountData(AccountId testAccount)
        {
            // ReSharper disable once InconsistentNaming
            const string ledger_index = "validated";
            var          account      = testAccount.ToString();
            var          parameters   = new { ledger_index, account };
            var          lines        = Ws.RequestAsync("account_lines", parameters);
            var          info         = Ws.RequestAsync("account_info", parameters);
            var          offers       = Ws.RequestAsync("account_offers", parameters);

            return(await Task.WhenAll(info, lines, offers));
        }
Exemplo n.º 17
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("AccountId=" + AccountId.ToString());
            sb.AppendLine("IsBasicAuthentication=" + IsBasicAuthentication.ToString());
            sb.AppendLine("Password="******"Url=" + Url.ToString());
            sb.AppendLine("UserName=" + UserName.ToString());

            return(sb.ToString());
        }
Exemplo n.º 18
0
        public static void GetDefaultRoomService(AccountId accountId, System.Action <XmlDocument> getDefaultRoomServiceCallback)
        {
            mLogger.DebugFormat("GetDefaultRoomService called accountId={0}", accountId);
            WebServiceRequest getDefaultRoomService = new WebServiceRequest(StateServerConfig.WebServicesBaseUrl, "Rooms", "GetRooms");

            getDefaultRoomService.AddParam("accountId", accountId.ToString());
            getDefaultRoomService.AddParam("isDefault", "1");
            getDefaultRoomService.GetWebResponseAsync(delegate(XmlDocument xmlResponse)
            {
                mLogger.DebugFormat("GetDefaultRoomService responded accountId={0} xmlResponse={1}", accountId, xmlResponse.OuterXml);
                getDefaultRoomServiceCallback(xmlResponse);
            });
        }
Exemplo n.º 19
0
        public static void UpdateAccountData(AccountId accountId, XmlDocument accountDataXml, Action <XmlDocument> updatedAccountDataCallback)
        {
            mLogger.DebugFormat("UpdateAccountData called accountId={0}", accountId);
            WebServiceRequest updateAccountDataService = new WebServiceRequest(StateServerConfig.WebServicesBaseUrl, "Accounts", "UpdateAccountData");

            updateAccountDataService.AddParam(ConstStrings.kAccountId, accountId.ToString());
            updateAccountDataService.AddParam(ConstStrings.kAccountData, accountDataXml.OuterXml);
            updateAccountDataService.GetWebResponseAsync(delegate(XmlDocument xmlResponse)
            {
                mLogger.DebugFormat("UpdateAccountData responded accountId={0}", accountId);
                updatedAccountDataCallback(xmlResponse);
            });
        }
Exemplo n.º 20
0
        public static void RemoveSession(AccountId accountId, string sessionId, Action <XmlDocument> updateStateServerCallback)
        {
            mLogger.DebugFormat("RemoveSession called accountId={0} sessionId={1}", accountId, sessionId);
            WebServiceRequest bossService = new WebServiceRequest(StateServerConfig.WebServicesBaseUrl, "Boss", "RemoveSession");

            bossService.AddParam("accountId", accountId.ToString());
            bossService.AddParam("sessionId", sessionId);
            bossService.GetWebResponseAsync(delegate(XmlDocument xmlResponse)
            {
                mLogger.DebugFormat("RemoveSession responded accountId={0} sessionId={1}", accountId, sessionId);
                updateStateServerCallback(xmlResponse);
            });
        }
Exemplo n.º 21
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("AccountId=" + AccountId.ToString());
            sb.AppendLine("AddSignature=" + AddSignature.ToString());
            sb.AppendLine("Content=" + Content.ToString());
            sb.AppendLine("Enabled=" + Enabled.ToString());
            sb.AppendLine("Html=" + Html.ToString());
            sb.AppendLine("Recipients=" + Recipients.ToString());
            sb.AppendLine("Subject=" + Subject.ToString());

            return(sb.ToString());
        }
Exemplo n.º 22
0
 public string GetTelemetryUserId()
 {
     if (IsDefaultOfflineAccount)
     {
         return("default-" + LocalAccountId);
     }
     else if (IsOnlineAccount)
     {
         return(AccountId.ToString());
     }
     else
     {
         return("offline-" + LocalAccountId);
     }
 }
Exemplo n.º 23
0
 public async Task <Account> GetAsync(AccountId id)
 {
     try
     {
         return(await _repo.GetAsync(id));
     }
     catch (AccountNotFoundException)
     {
         var info = new Dictionary <string, string>()
         {
             ["Id"] = id.ToString()
         };
         throw new WPayException(AccountErrors.AccountNotExist, info);
     }
 }
Exemplo n.º 24
0
 internal LoginSession(Client client, AccountId accountId)
 {
     if (AccountId.IsNullOrEmpty(accountId))
     {
         throw new ArgumentNullException(nameof(accountId));
     }
     if (client == null)
     {
         throw new ArgumentNullException(nameof(client));
     }
     Key            = accountId;
     _accountHandle = accountId.ToString();
     _groupHandle   = "sg_" + _accountHandle;
     _client        = client;
     VxClient.Instance.EventMessageReceived += Instance_EventMessageReceived;
 }
Exemplo n.º 25
0
        public async Task LockAsync(AccountId id, bool locked)
        {
            try
            {
                var acc = await _repo.GetAsync(id, true);

                var newAcc = new Account(acc.Id, acc.Balance, locked);
                await _repo.UpdateAsync(newAcc);
            }
            catch (AccountNotFoundException)
            {
                var info = new Dictionary <string, string>()
                {
                    ["Id"] = id.ToString()
                };
                throw new WPayException(AccountErrors.AccountNotExist, info);
            }
        }
Exemplo n.º 26
0
        public override string ToString()
        {
            var result = string.Empty;

            if (!string.IsNullOrWhiteSpace(Nickname))
            {
                result = Nickname;
            }
            else if (AccountId != 0)
            {
                result = AccountId.ToString();
            }
            else
            {
                result = base.ToString();
            }

            return(result);
        }
Exemplo n.º 27
0
        public IAsyncResult BeginSendDirectedMessage(AccountId userId, string language, string message, string applicationStanzaNamespace, string applicationStanzaBody, AsyncCallback callback)
        {
            if (AccountId.IsNullOrEmpty(userId))
            {
                throw new ArgumentNullException(nameof(userId));
            }
            if (string.IsNullOrEmpty(message) && string.IsNullOrEmpty(applicationStanzaBody))
            {
                throw new ArgumentNullException($"{nameof(message)} and {nameof(applicationStanzaBody)} cannot both be null");
            }

            AssertLoggedIn();
            AsyncNoResult ar = new AsyncNoResult(callback);

            var request = new vx_req_account_send_message_t
            {
                account_handle = _accountHandle,
                message_body   = message,
                user_uri       = userId.ToString(),
                language       = language,
                application_stanza_namespace = applicationStanzaNamespace,
                application_stanza_body      = applicationStanzaBody
            };

            VxClient.Instance.BeginIssueRequest(request, result =>
            {
                vx_resp_account_send_message_t response;
                try
                {
                    response = VxClient.Instance.EndIssueRequest(result);
                    _directedMessageResult = new DirectedMessageResult(response.request_id);
                    PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(DirectedMessageResult)));
                    ar.SetComplete();
                }
                catch (Exception e)
                {
                    VivoxDebug.Instance.VxExceptionMessage($"{request.GetType().Name} failed: {e}");
                    ar.SetComplete(e);
                    return;
                }
            });
            return(ar);
        }
 private async Task CreateShipment()
 {
     try
     {
         var req = new GrpcNewShipmentRequest()
         {
             TrackingCode           = MLShipment.TrackingCode,
             SetAutoUpdate          = true,
             MarketplaceAccountId   = AccountId.ToString(),
             MarketplaceSaleId      = MLShipment.OrderId.ToString(),
             BoundMarketplace       = "mercado livre",
             SetCreatedManually     = false,
             ShippingImplementation = GetShipmentImplementation(),
             PackageData            = new GrpcNewPackageRequest()
         };
         await ShippingClient.CreateShipment(req);
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 29
0
        public async Task <ActionResult <ApiResultViewModel <FriendRequest> > > GetFriendRequests(
            [FromQuery] QueryInputModel <FriendRequestFilterInputModel> filterInputModel,
            CancellationToken cancellationToken)
        {
            var fromAccountId = filterInputModel.FilterParameters.FirstOrDefault(q =>
                                                                                 q.FieldName == nameof(FriendRequestFilterInputModel.FromAccountId));

            var toAccountId = filterInputModel.FilterParameters.FirstOrDefault(q =>
                                                                               q.FieldName == nameof(FriendRequestFilterInputModel.ToAccountId));

            if ((fromAccountId == null || !string.Equals(fromAccountId.Values[0], AccountId.ToString(),
                                                         StringComparison.OrdinalIgnoreCase)) &&
                (toAccountId == null || !string.Equals(toAccountId.Values[0], AccountId.ToString(),
                                                       StringComparison.OrdinalIgnoreCase)))
            {
                return(Forbidden());
            }

            var friendRequests = await _friendRequestManager.GetAllAsync(filterInputModel, cancellationToken);

            return(OkData(friendRequests.Data, friendRequests.TotalCount));
        }
 private List <UriParam> GetParams()
 {
     return(new List <UriParam>()
     {
         new UriParam()
         {
             Name = "seller", Data = AccountId.ToString()
         },
         new UriParam()
         {
             Name = "access_token", Data = AccessToken
         },
         new UriParam()
         {
             Name = "offset", Data = Pagination.Offset.ToString()
         },
         new UriParam()
         {
             Name = "limit", Data = Pagination.Limit.ToString()
         },
     });
 }