示例#1
0
        /// <summary>
        /// 固定長のリクエストを送信し、レスポンスのポインタを返す
        /// </summary>
        /// <param name="url">接続先パス</param>
        /// <param name="id">ProfileID</param>
        /// <param name="request">リクエストデータ</param>
        /// <param name="outPtr">レスポンスを指したポインタ</param>
        /// <param name="outSize">レスポンスサイズ</param>
        internal void Session(string url, int id, object request, out IntPtr outPtr, out uint outSize)
        {
            uint   realSize = 0;
            IntPtr ptr      = Marshal.AllocCoTaskMem(Marshal.SizeOf(request));

            Marshal.StructureToPtr(request, ptr, false);

            try
            {
                lock (this)
                {
                    EncSession.DWC_EncSessionGetAsync(url, id, ptr, (uint)Marshal.SizeOf(request), 0);
                    if (!WaitForResponse())
                    {
                        throw new Exception("HTTPエラー");
                    }
                    outPtr = EncSession.DWC_EncSessionGetResponse(ref realSize);
                }
            }
            finally
            {
                Marshal.FreeCoTaskMem(ptr);
            }
            outSize = realSize;
            //MessageBox.Show("PTR: " + resultPtr + " size : " + realSize + " send size: " + Marshal.SizeOf(request));
        }
示例#2
0
        /// <summary>
        /// 可変長のリクエストを送信し、レスポンスのポインタを返す
        /// </summary>
        /// <param name="url">接続先パス</param>
        /// <param name="id">ProfileID</param>
        /// <param name="inPtr">リクエストを格納したbyte列</param>
        /// <param name="outPtr">レスポンスを指したポインタ</param>
        /// <param name="outSize">レスポンスサイズ</param>
        internal void Session(string url, int id, byte[] bytes, out IntPtr outPtr, out uint outSize)
        {
            uint   realSize = 0;
            int    inSize   = 0;
            IntPtr inPtr    = new IntPtr();

            if (bytes == null || bytes.Length == 0)
            {
                //throw new Exception("入力データが空です。");
            }
            else
            {
                inSize = Marshal.SizeOf(bytes[0]) * bytes.Length;
                inPtr  = Marshal.AllocHGlobal(inSize);
            }

            try
            {
                if (bytes.Length != 0)
                {
                    Marshal.Copy(bytes, 0, inPtr, bytes.Length);
                }

                lock (this)
                {
                    EncSession.DWC_EncSessionGetAsync(url, id, inPtr, (uint)inSize, 0);
                    if (!WaitForResponse())
                    {
                        throw new Exception("HTTPエラー");
                    }
                    outPtr = EncSession.DWC_EncSessionGetResponse(ref realSize);
                }
            }
            finally
            {
                Marshal.FreeHGlobal(inPtr);
            }

            outSize = realSize;
            //MessageBox.Show("PTR: " + resultPtr + " size : " + realSize + " send size: " + Marshal.SizeOf(request));
        }