Exemplo n.º 1
0
        /// <summary>
        /// Sends the request data synchronously.
        /// </summary>
        /// <exception cref="ArgumentException">Thrown when the argument is invalid.</exception>
        /// <exception cref="OutOfMemoryException">Thrown when the memory is insufficient.</exception>
        /// <exception cref="UnauthorizedAccessException">Thrown when because of permission denied.</exception>
        /// <exception cref="global::System.IO.IOException">Thrown when because of I/O error.</exception>
        /// <param name="endpoint">The name of the endpoint</param>
        /// <param name="timeout">The interval of timeout</param>
        /// <param name="request">The serializable data to send</param>
        /// <returns>The received serializable data</returns>
        /// /// <since_tizen> 9 </since_tizen>
        public object SendSync(string endpoint, int timeout, object request)
        {
            if (request == null)
            {
                throw new ArgumentException("request is null");
            }

            if (!request.GetType().IsSerializable)
            {
                throw new ArgumentException("request is not serializable");
            }

            SafeParcelHandle resSafeHandle = null;

            Interop.ComponentPort.ErrorCode err;
            using (Parcel reqParcel = ToParcel(request))
            {
                err = Interop.ComponentPort.SendSync(_port, endpoint, timeout, reqParcel.SafeParcelHandle, out resSafeHandle);
            }
            if (err != Interop.ComponentPort.ErrorCode.None)
            {
                throw ComponentPortErrorFactory.GetException(err, "Failed to send the request.");
            }

            using (Parcel resParcel = new Parcel(resSafeHandle))
            {
                object response = FromParcel(resParcel);
                return(response);
            }
        }
Exemplo n.º 2
0
        private void OnSyncRequestEvent(string sender, IntPtr request, IntPtr response, IntPtr data)
        {
            SafeParcelHandle reqSafeHandle = new SafeParcelHandle(request, false);

            object req = null;

            using (Parcel reqParcel = new Parcel(reqSafeHandle))
            {
                req = FromParcel(reqParcel);
            }

            object result = OnSyncRequestEvent(sender, req);

            if (!result.GetType().IsSerializable)
            {
                Log.Error(LogTag, "result is not serializable");
            }
            else
            {
                SafeParcelHandle resSafeHandle = new SafeParcelHandle(response, false);
                using (Parcel resParcel = new Parcel(resSafeHandle))
                {
                    using (Parcel resultParcel = ToParcel(result))
                    {
                        resParcel.UnMarshall(resultParcel.Marshall());
                    }
                }
            }
        }
Exemplo n.º 3
0
        public Parcel(SafeParcelHandle handle)
        {
            if (handle == null)
            {
                throw new ArgumentException("handle is null");
            }

            _handle = handle;
        }
Exemplo n.º 4
0
        private void OnRequestEvent(string sender, IntPtr request, IntPtr data)
        {
            SafeParcelHandle reqSafeHandle = new SafeParcelHandle(request, false);

            using (var reqParcel = new Parcel(reqSafeHandle))
            {
                object req = FromParcel(reqParcel);
                OnRequestEvent(sender, req);
            }
        }
Exemplo n.º 5
0
        private void OnRequestEvent(string sender, IntPtr request, IntPtr data)
        {
            SafeParcelHandle reqSafeHandle = new SafeParcelHandle(request, false);

            using (var reqParcel = new Parcel(reqSafeHandle))
            {
                object req = FromParcel(reqParcel);
                RequestReceived?.Invoke(this, new RequestEventArgs(sender, req, false));
            }
        }
Exemplo n.º 6
0
        private void OnSyncRequestEvent(string sender, IntPtr request, IntPtr response, IntPtr data)
        {
            SafeParcelHandle reqSafeHandle = new SafeParcelHandle(request, false);

            object req = null;

            using (Parcel reqParcel = new Parcel(reqSafeHandle))
            {
                req = FromParcel(reqParcel);
            }

            var args = new RequestEventArgs(sender, req, true);

            RequestReceived?.Invoke(this, args);

            var result = args.Reply;

            if (result == null)
            {
                Log.Error(LogTag, "result is null");
            }
            else if (!result.GetType().IsSerializable)
            {
                Log.Error(LogTag, "result is not serializable");
            }
            else
            {
                SafeParcelHandle resSafeHandle = new SafeParcelHandle(response, false);
                using (Parcel resParcel = new Parcel(resSafeHandle))
                {
                    using (Parcel resultParcel = ToParcel(result))
                    {
                        if (resultParcel != null)
                        {
                            resParcel.UnMarshall(resultParcel.Marshall());
                        }
                        else
                        {
                            Log.Error(LogTag, "Result parcel is null");
                        }
                    }
                }
            }
        }
Exemplo n.º 7
0
 internal static extern ErrorCode WriteBool(SafeParcelHandle handle, bool val);
Exemplo n.º 8
0
 internal static extern ErrorCode BurstWrite(SafeParcelHandle handle, byte[] buf, UInt32 size);
Exemplo n.º 9
0
 internal static extern ErrorCode BurstRead(SafeParcelHandle handle, [In, Out] byte[] buf, UInt32 size);
Exemplo n.º 10
0
 internal static extern ErrorCode ReadBool(SafeParcelHandle handle, out bool val);
Exemplo n.º 11
0
 internal static extern ErrorCode DangerousClone(IntPtr handle, out SafeParcelHandle clone);
Exemplo n.º 12
0
 internal static extern ErrorCode WriteInt64(SafeParcelHandle handle, Int64 val);
Exemplo n.º 13
0
 internal static extern ErrorCode WriteFloat(SafeParcelHandle handle, float val);
Exemplo n.º 14
0
 internal static extern ErrorCode ReadString(SafeParcelHandle handle, out string val);
Exemplo n.º 15
0
 internal static extern ErrorCode Send(IntPtr handle, string endpoint, Int32 timeout, SafeParcelHandle request);
Exemplo n.º 16
0
 internal static extern ErrorCode ReadFloat(SafeParcelHandle handle, out float val);
Exemplo n.º 17
0
 internal static extern ErrorCode ReadDouble(SafeParcelHandle handle, out double val);
Exemplo n.º 18
0
 internal static extern ErrorCode ReadInt64(SafeParcelHandle handle, out Int64 val);
Exemplo n.º 19
0
 internal static extern ErrorCode ReadUInt32(SafeParcelHandle handle, out UInt32 val);
Exemplo n.º 20
0
 internal static extern ErrorCode ReadByte(SafeParcelHandle handle, out byte val);
Exemplo n.º 21
0
 internal static extern ErrorCode WriteByte(SafeParcelHandle handle, byte val);
Exemplo n.º 22
0
 internal static extern ErrorCode WriteString(SafeParcelHandle handle, string str);
Exemplo n.º 23
0
 internal static extern ErrorCode WriteUInt32(SafeParcelHandle handle, UInt32 val);
Exemplo n.º 24
0
 internal static extern ErrorCode Reset(SafeParcelHandle handle, byte[] buf, UInt32 size);
Exemplo n.º 25
0
 internal static extern ErrorCode WriteDouble(SafeParcelHandle handle, double val);
Exemplo n.º 26
0
 internal static extern ErrorCode Create(out SafeParcelHandle handle);
Exemplo n.º 27
0
 internal static extern ErrorCode ReadBundle(SafeParcelHandle handle, out IntPtr b);
Exemplo n.º 28
0
 internal static extern ErrorCode WriteBundle(SafeParcelHandle handle, IntPtr b);
Exemplo n.º 29
0
 internal static extern ErrorCode SendSync(IntPtr handle, string endpoint, Int32 timeout, SafeParcelHandle request, out SafeParcelHandle response);
Exemplo n.º 30
0
 internal static extern ErrorCode GetRaw(SafeParcelHandle handle, out IntPtr raw, out UInt32 size);