コード例 #1
0
        public static void OnClientProductsResponse <T>(NetworkMessage netMsg) where T : BaseIAPProduct
        {
            MsgResponseProductsFromServer msg = netMsg.ReadMessage <MsgResponseProductsFromServer>();
            IAPProducts <T> productsList      = JsonUtility.FromJson <IAPProducts <T> >(msg.jsonProducts);

            if (onClientProductsResponse != null)
            {
                onClientProductsResponse(productsList.ToBaseList());
            }
        }
コード例 #2
0
        public static void OnServerProductsRequest <T>(NetworkMessage netMsg) where T : BaseIAPProduct
        {
            // TODO: May receive type of list via message
            MsgRequestProductsFromClient msg = netMsg.ReadMessage <MsgRequestProductsFromClient>();
            List <T> iapProducts             = new List <T>();
            var      keyValueList            = IAPManager <T> .Instance.ConsumableProducts.GetEnumerator();

            while (keyValueList.MoveNext())
            {
                iapProducts.Add(keyValueList.Current.Value as T);
            }

            IAPProducts <T> productsList = new IAPProducts <T>();

            productsList.iapProducts = iapProducts;

            MsgResponseProductsFromServer resMsg = new MsgResponseProductsFromServer();

            resMsg.jsonProducts = JsonUtility.ToJson(productsList);
            netMsg.conn.Send(MsgResponseProductsFromServer.MsgId, resMsg);
        }