예제 #1
0
            public IEnumerator RequestPlayerItemsRoutine(RequestPlayerItems requestPlayerItems, IInventoryApi caller)
            {
                string uri = NetworkSettings.instance.BaseUri() + "/api/game/inventory/request_player_items";
                var form = new WWWForm();
                form.AddField("playerId", NetworkSettings.instance.username);
                form.AddField("authtoken", NetworkSettings.instance.authtoken);

                MemoryStream stream = new MemoryStream();
                Serializer.Serialize(stream, requestPlayerItems);
                string content = System.Convert.ToBase64String(stream.ToArray());
                form.AddField("content", content);

                WWW www = new WWW(uri, form.data, form.headers);
                yield return www;

                if (www.error != null) {
                    caller.OnRequestPlayerItemsError(www.error);
                } else {
                    stream = new MemoryStream(www.bytes);
                    requestPlayerItems = Serializer.Deserialize<RequestPlayerItems>(stream);
                    caller.OnRequestPlayerItems(requestPlayerItems);
                }
            }
예제 #2
0
 public void RequestPlayerItems(RequestPlayerItems requestPlayerItems, IInventoryApi caller)
 {
     StartCoroutine(RequestPlayerItemsRoutine(requestPlayerItems, caller));
 }
예제 #3
0
 public void GetItems()
 {
     RequestPlayerItems requestPlayerItems = new RequestPlayerItems();
     requestPlayerItems.catalog = true;
     messageHandler.Send(requestPlayerItems, Destination.Inventory);
 }