//int rpc_port_parcel_header_get_timestamp(rpc_port_parcel_header_h header, struct timespec *timestamp);
[DllImport(Libraries.RpcPort, EntryPoint = "rpc_port_parcel_header_get_timestamp")]
internal static extern ErrorCode GetTimeStamp(IntPtr parcelHeaderHandle, ref Libc.TimeStamp time);
+
+ //int rpc_port_parcel_get_raw(rpc_port_parcel_h h, void **raw, unsigned int *size);
+ [DllImport(Libraries.RpcPort, EntryPoint = "rpc_port_parcel_get_raw")]
+ internal static extern ErrorCode GetRaw(IntPtr parcelHandle, out IntPtr raw, out uint size);
+
+ //int rpc_port_parcel_create_from_raw(rpc_port_parcel_h *h, const void *raw, unsigned int size);
+ [DllImport(Libraries.RpcPort, EntryPoint = "rpc_port_parcel_create_from_raw")]
+ internal static extern ErrorCode CreateFromRaw(out IntPtr parcelHandle, byte[] raw, uint size);
}
internal static partial class Proxy
*/
using System;
+using System.Runtime.InteropServices;
namespace Tizen.Applications.RPCPort
{
}
/// <summary>
+ /// Constructor with the raw bytes.
+ /// </summary>
+ /// <param name="bytes">The raw bytes.</param>
+ /// <exception cref="InvalidIOException">Thrown when an internal IO error occurs.</exception>
+ /// <since_tizen> 9 </since_tizen>
+ public Parcel(byte[] bytes)
+ {
+ if (bytes == null)
+ throw new InvalidIOException();
+ var r = Interop.LibRPCPort.Parcel.CreateFromRaw(out _handle, bytes, (uint)bytes.Length);
+ if (r != Interop.LibRPCPort.ErrorCode.None)
+ throw new InvalidIOException();
+ }
+
+ /// <summary>
+ /// Gets the raw bytes of the parcel.
+ /// </summary>
+ /// <returns>The raw bytes of the parcel.</returns>
+ /// <exception cref="InvalidIOException">Thrown when an internal IO error occurs.</exception>
+ /// <since_tizen> 9 </since_tizen>
+ public byte[] ToBytes()
+ {
+ var r = Interop.LibRPCPort.Parcel.GetRaw(_handle, out IntPtr raw, out uint size);
+ if (r != Interop.LibRPCPort.ErrorCode.None)
+ throw new InvalidIOException();
+ byte[] bytes = new byte[size];
+ Marshal.Copy(raw, bytes, 0, (int)size);
+ return bytes;
+ }
+
+ /// <summary>
/// Sends parcel data through the port.
/// </summary>
/// <param name="p">The RPC port object for writing data.</param>