protected virtual int OnDeviceMethodReceived(DeviceMethodCallbackArgs e) { EventHandler <DeviceMethodCallbackArgs> handler = DeviceMethodCallback; if (handler != null) { handler(this, e); } return(e.Result); }
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); }