1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using LitJson;
- using System;
- public class Network {
- public bool active = false;
- public string action;
- public JsonData data;
- public string url;
- private Action<string> failedFun;
- private Action<JsonData> successFun;
- /// <summary>
- /// Init the specified action, data, type, success and failed.
- /// </summary>
- /// <param name="action">Action.</param>
- /// <param name="data">Data.</param>
- /// <param name="success">Success.</param>
- /// <param name="failed">Failed.</param>
- public void init(string action, JsonData data,Action<JsonData> successFun = null ,Action<string> failedFun = null)
- {
- this.action = action;
- this.data = data;
- this.successFun = successFun;
- this.failedFun = failedFun;
- active = false;
- this.url = action;
- }
- public void scuess(JsonData data)
- {
- if (successFun != null) {
- successFun (data);
- }
- }
- public void failed (string msg)
- {
- if (failedFun != null) {
- failedFun (msg);
- }
- }
- public void error(string msg)
- {
- if (failedFun != null) {
- failedFun (msg);
- }
- }
- }
|