Ejemplo n.º 1
0
        protected virtual int OnDeviceMethodReceived(DeviceMethodCallbackArgs e)
        {
            EventHandler <DeviceMethodCallbackArgs> handler = DeviceMethodCallback;

            if (handler != null)
            {
                handler(this, e);
            }

            return(e.Result);
        }
Ejemplo n.º 2
0
        private int deviceMethodReceived(IntPtr method, IntPtr payload, int size, out IntPtr response, out int response_size, UIntPtr userContextCallback)
        {
            string strMethod = Marshal.PtrToStringAnsi(method);
            DeviceMethodCallbackArgs deviceMethodCallbackArgs = new DeviceMethodCallbackArgs(strMethod, payload, size, userContextCallback);

            int result = OnDeviceMethodReceived(deviceMethodCallbackArgs);
            int length = deviceMethodCallbackArgs.Response.Length + 1;

            byte[] work = Encoding.UTF8.GetBytes(deviceMethodCallbackArgs.Response);

            // This call to malloc may not be reliable but is forced upon the code by the C SDK
            response = malloc(work.Length);
            Marshal.Copy(work, 0, response, work.Length);
            response_size = work.Length;

            return(result);
        }