Exemple #1
0
        /// <summary>
        /// インスタンス生成:通信情報から生成
        /// </summary>
        public static NetResponse Create(NetCommand cmd, NetConnector con)
        {
            var instance = new NetResponse();

            instance.Command = cmd;
            if (con == null)
            {
                instance.IsConnectError = true;
                return(instance);
            }
            Debug.Log("[NetResponse] IsError = " + con.IsError.ToString() + (con.IsError ? "" : ", data size = " + con.WWW.bytes.Length.ToString()));
            if (con.IsError)
            {
                instance.IsConnectError = true;
                return(instance);
            }

            var result = instance.UnpackObject(con.ResponseData);

            if (result == null)
            {
                Debug.LogError("[NetResponse] Parse Error!! : " + cmd.ToString());
                return(instance);
            }

            instance.ParseResultBase(result);
            // TODO : 結果をDumpしたいなどあれば追記.
            instance.ResultObjects = ParseResultObjects(result);
            return(instance);
        }