private void OnDMarketTransaction(AppDMarketTransactionMessage marketMessage)
        {
            var actionType = CovertMarketAction(marketMessage.TransactionData.TransactionType);
            var appMessage = new AppChangingItemsMessage(actionType)
            {
                ConnectionId = marketMessage.ConnectionId
            };

            for (var i = 0; i < marketMessage.TransactionData.AssetIds.Count; i++)
            {
                var assetId  = marketMessage.TransactionData.AssetIds[i];
                var classId  = marketMessage.TransactionData.ClassIds[i];
                var worldId  = DMarketConverter.GetWorldId(assetId);
                var itemType = DMarketConverter.GetItemType(classId);
                appMessage.AddItem(worldId, itemType);
            }

            OnItemChangingMsg(appMessage);
        }
예제 #2
0
        private void OnLoadDMarketDataMsg(AppLoadDMarketDataMessage message)
        {
            int connectionId = message.ConnectionId;

            if (!IsCanMakeDMarketOperation(connectionId))
            {
                return;
            }

            DMarketApi.GetInMarketInventory(Model.GetPlayerMarketAccessToken(connectionId),
                                            (response, request) =>
            {
                PlayerInfo playerInfo = GetPlayer(connectionId);

                PlayerInventoryInfo inventory = GetInventory(connectionId);
                playerInfo.Inventory          = inventory;
                inventory.RemoveAllDMarketItems();

                foreach (var item in response.Items)
                {
                    GameItemType itemType = DMarketConverter.GetItemType(item.classId);
                    long worldId          = DMarketConverter.GetWorldId(item.assetId);

                    PlayerItemInfo dmarketItem = new PlayerItemInfo(itemType, worldId, true);
                    inventory.AddItem(dmarketItem);
                }

                Storage.Change(playerInfo);

                SendDmarketDataUpdateAnswer(connectionId);
            },
                                            error =>
            {
                if (error.ErrorCode == ErrorCode.DMarketTokenExpired)
                {
                    RefreshMarketToken(connectionId, () => OnLoadDMarketDataMsg(message),
                                       errorParam => SendLoadDMarketLoadDataError(connectionId, errorParam));
                    return;
                }

                SendLoadDMarketLoadDataError(connectionId, error.ErrorCode);
            });
        }
예제 #3
0
        private void OnLoadInventoryBasicIntegration(InventoryBasicIntegrationMessage message)
        {
            int connectionId = message.ConnectionId;

            if (!IsCanMakeDMarketOperation(connectionId))
            {
                return;
            }

            DMarketApi.GetInMarketInventory(Model.GetPlayerMarketAccessToken(connectionId),
                                            (response, request) =>
            {
                List <ItemInfo> itemsList = new List <ItemInfo>();
                foreach (var item in response.Items)
                {
                    GameItemType itemType = DMarketConverter.GetItemType(item.classId);
                    long worldId          = DMarketConverter.GetWorldId(item.assetId);

                    ItemInfo dmarketItem = new ItemInfo(worldId, itemType);
                    itemsList.Add(dmarketItem);
                }

                if (itemsList.Count == 0)
                {
                    SendLoadInventoryData(connectionId);
                    return;
                }

                ApplyCommand(new ServerBulkTransferInventoryBasicIntegrationCommand(itemsList, ItemActionType.FromMarket, connectionId));
            },
                                            error =>
            {
                if (error.ErrorCode == ErrorCode.DMarketTokenExpired)
                {
                    RefreshMarketToken(connectionId, () => OnLoadInventoryBasicIntegration(message),
                                       errorCode => SendLoadInventoryData(connectionId, errorCode));
                    return;
                }

                SendLoadInventoryData(connectionId, error.ErrorCode);
            });
        }