// Use this for initialization void Start() { // testT(); string url = "http://www.caishenlaile.com/game/basic/login"; HttpProxy.SendPostRequest <LoginMessage>(url, new Dictionary <string, object>(), (res, msg) => { // Debug.Log(user.data.ToString()); if (!msg.isOK) { Debug.Log(msg.errmsg); } else { Debug.Log(msg.ToString()); wsp = new WebSocketProxy("ws://10.0.2.55:8080/ws/conn?uid=2"); wsp.onOpen += () => { Debug.Log("on open"); wsp.send("{\"cmd\":\"info\",\"fromid\":\"1\",\"toid\":\"2\",\"content\":\"hello?\"}"); }; wsp.onMessage += (s) => { Debug.Log("onMessage" + s); }; wsp.onError += (s) => { Debug.Log("onError"); }; } }); }
private bool Send(Dictionary <string, object> data, Action <bool, PlayerDataMessage> callBack) { var url = Configure.instance.ServerUrl; return(HttpProxy.SendPostRequest <PlayerDataMessage>(url, data, (ret, res) => { if (ret) { if (res.isOK) { GameMainManager.Instance.playerData.RefreshData(res as PlayerDataMessage); } else { Debug.Log("-----服务器返回错误:" + res.errMsg + "-----"); Debug.LogWarning("-----服务器返回错误:" + res.errMsg + "-----"); ui.Alert.Show(GetMsgByErrorCode(res.err)); } callBack(ret, res); queue.Dequeue(); bufferQueue.Dequeue(); } isSending = false; })); }