* limitations under the License.
*/
+using System;
+using System.Runtime.InteropServices;
+
internal static partial class Interop
{
internal static partial class Cion
TimedOut = Tizen.Internals.Errors.ErrorCode.TimedOut,
OperationFailed = -0x030C0000 | 0x01,
}
+
+ [DllImport(Libraries.Libc, EntryPoint = "malloc")]
+ internal static extern IntPtr Malloc(int size);
}
}
internal delegate void CionServerConnectionResultCb(string serviceName, IntPtr peerInfo, IntPtr result, IntPtr userData);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- internal delegate void CionServerDataReceivedCb(string serviceName, IntPtr peerInfo, byte[] data, int dataSize, out byte[] returnData, out int returnDataSize, IntPtr userData);
+ internal delegate void CionServerDataReceivedCb(string serviceName, IntPtr peerInfo, byte[] data, int dataSize, out IntPtr returnData, out int returnDataSize, IntPtr userData);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate void CionServerPayloadReceivedCb(string serviceName, IntPtr peerInfo, IntPtr payload, int status, IntPtr userData);
internal static partial class Libraries
{
public const string Cion = "libcion.so.1";
+ public const string Libc = "libc.so.6";
}
}
private Interop.CionClient.CionClientConnectionResultCb _connectionResultCb;
private Interop.CionClient.CionClientPayloadReceivedCb _payloadRecievedCb;
private Interop.CionClient.CionClientDisconnectedCb _disconnectedCb;
- private Interop.CionClient.CionClientPayloadAsyncResultCb _payloadAsyncResultCb;
private Dictionary<string, TaskCompletionSource<PayloadAsyncResult>> _tcsDictionary = new Dictionary<string, TaskCompletionSource<PayloadAsyncResult>>();
private Dictionary<string, Interop.CionClient.CionClientPayloadAsyncResultCb> _payloadAsyncCbDictionary = new Dictionary<string, Interop.CionClient.CionClientPayloadAsyncResultCb>();
_tcsDictionary.Remove(resultPayload.PayloadId);
});
- Interop.Cion.ErrorCode ret = Interop.CionClient.CionClientSendPayloadAsync(_handle, payload?._handle, _payloadAsyncResultCb, IntPtr.Zero);
+ Interop.Cion.ErrorCode ret = Interop.CionClient.CionClientSendPayloadAsync(_handle, payload?._handle, cb, IntPtr.Zero);
if (ret != Interop.Cion.ErrorCode.None)
{
throw CionErrorFactory.GetException(ret, "Failed to send payload.");
using System;
using System.Collections.Generic;
+using System.Runtime.InteropServices;
using System.Threading.Tasks;
namespace Tizen.Applications.Cion
}
_dataReceivedCb = new Interop.CionServer.CionServerDataReceivedCb(
- (string service, IntPtr peerInfo, byte[] data, int dataSize, out byte[] returnData, out int returnDataSize, IntPtr userData) =>
+ (string service, IntPtr peerInfo, byte[] data, int dataSize, out IntPtr returnData, out int returnDataSize, IntPtr userData) =>
{
Interop.Cion.ErrorCode clone_ret = Interop.CionPeerInfo.CionPeerInfoClone(peerInfo, out PeerInfoSafeHandle clone);
if (clone_ret != Interop.Cion.ErrorCode.None)
{
Log.Error(LogTag, "Failed to clone peer info.");
- returnData = null;
+ returnData = IntPtr.Zero;
returnDataSize = -1;
}
- returnData = OnDataReceived(data, new PeerInfo(clone));
- returnDataSize = returnData.Length;
+ byte[] returnDataRaw = OnDataReceived(data, new PeerInfo(clone));
+ returnDataSize = returnDataRaw.Length;
+ returnData = Interop.Cion.Malloc(returnDataSize);
+ Marshal.Copy(returnDataRaw, 0, returnData, returnDataSize);
});
ret = Interop.CionServer.CionServerSetDataReceivedCb(_handle, _dataReceivedCb, IntPtr.Zero);
if (ret != Interop.Cion.ErrorCode.None)