Exemplo n.º 1
0
 /// <summary>
 /// 向服务器发送消息,并接收来自服务器的回复消息
 /// </summary>
 /// <param name="_strBytes">发送给服务器的字节</param>
 /// <param name="_respondFunction">服务器返回给客户端的回调数据</param>
 void ReceiveMessage(byte[] _strBytes, RespondOfHttpJD _respondFunction)
 {
     try
     {
         this.ClientSocket.Send(_strBytes);
         _respondFunction?.Invoke(AsynRecive(ClientSocket));
     }
     catch (Exception ex)
     {
         Debug.LogError("写Error日志" + ex.ToString());
     }
 }
Exemplo n.º 2
0
        private IEnumerator <WWW> RequestServer(byte[] _strBytes, RespondOfHttpJD _respondFunction)
        {
            using (WWW www = new WWW("http://127.0.0.1:2017", _strBytes))
            {
                yield return(www);

                if (www.error == null)
                {
                    string wwwStr = www.text;
                    Debug.Log("wwwStr:" + wwwStr);
                    JsonData jd2 = JsonMapper.ToObject(wwwStr.Replace("[[", "[{").Replace("]]", "}]"));
                    JsonData jd  = JsonMapper.ToObject(wwwStr);
                    _respondFunction?.Invoke(jd);
                }
                else
                {
                    Debug.Log(www.error);
                }
            }
        }