private void doBaseCallback(string jsonParam) { JSONNode jsonData = JSON.Parse(jsonParam); int callbackId = jsonData ["callbackid"].AsInt; string on = (string)jsonData ["on"]; EMBaseCallback cb = EMClient.Instance.GetCallbackById(callbackId); if (on.Equals("success")) { cb.onSuccessCallback(); EMClient.Instance.RemoveCallbackById(callbackId); } else if (on.Equals("progress")) { cb.onProgressCallback(jsonData ["progress"].AsInt, jsonData ["status"].Value); } else if (on.Equals("error")) { cb.onErrorCallback(jsonData ["code"].AsInt, jsonData ["message"].Value); EMClient.Instance.RemoveCallbackById(callbackId); } else { cb.onErrorCallback(-999999, "unknown error"); EMClient.Instance.RemoveCallbackById(callbackId); } }
//TODO 成功接收消息回到后应该从消息列表中删除消息【 invoke EMClient.Instance.RemoveCallbackById()】 public void SendMessageCallback(string jsonParam) { JsonData jsonData = JsonMapper.ToObject(jsonParam); int callbackId = (int)jsonData ["callbackid"]; Debug.LogError("callbackId=" + callbackId); EMBaseCallback cb = EMClient.Instance.GetCallbackById(callbackId); if (cb != null) { string on = (string)jsonData ["on"]; if (on.Equals("success")) { cb.onSuccessCallback(); EMClient.Instance.RemoveCallbackById(callbackId); } else if (on.Equals("progress")) { cb.onProgressCallback((int)jsonData ["progress"], (string)jsonData ["status"]); } else if (on.Equals("error")) { cb.onErrorCallback((int)jsonData ["code"], (string)jsonData ["message"]); } else { cb.onErrorCallback(-999999, "unknown error"); } } }
//TODO 成功接收消息回到后应该从消息列表中删除消息【 invoke EMClient.Instance.RemoveCallbackById()】 public void SendMessageCallback(string jsonParam) { JSONNode jsonData = JSON.Parse(jsonParam); int callbackId = jsonData ["callbackid"].AsInt; Debug.LogError("callbackId=" + callbackId); EMBaseCallback cb = EMClient.Instance.GetCallbackById(callbackId); if (cb != null) { string on = jsonData ["on"].Value; if (on.Equals("success")) { cb.onSuccessCallback(); EMClient.Instance.RemoveCallbackById(callbackId); } else if (on.Equals("progress")) { cb.onProgressCallback(jsonData ["progress"].AsInt, jsonData ["status"].Value); } else if (on.Equals("error")) { cb.onErrorCallback(jsonData ["code"].AsInt, jsonData ["message"].Value); } else { cb.onErrorCallback(-999999, "unknown error"); } } }