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); } }
public void RequestPlayerItems(RequestPlayerItems requestPlayerItems, IInventoryApi caller) { StartCoroutine(RequestPlayerItemsRoutine(requestPlayerItems, caller)); }
public void GetItems() { RequestPlayerItems requestPlayerItems = new RequestPlayerItems(); requestPlayerItems.catalog = true; messageHandler.Send(requestPlayerItems, Destination.Inventory); }