/** * Constructor for a SessionListener. */ public SessionListener() { _sessionLost = new InternalSessionLost(this._SessionLost); _sessionMemberAdded = new InternalSessionMemberAdded(this._SessionMemberAdded); _sessionMemberRemoved = new InternalSessionMemberRemoved(this._SessionMemberRemoved); callbacks.sessionLost = Marshal.GetFunctionPointerForDelegate(_sessionLost); callbacks.sessionMemberAdded = Marshal.GetFunctionPointerForDelegate(_sessionMemberAdded); callbacks.sessionMemberRemoved = Marshal.GetFunctionPointerForDelegate(_sessionMemberRemoved); main = GCHandle.Alloc(callbacks, GCHandleType.Pinned); _sessionListener = alljoyn_sessionlistener_create(main.AddrOfPinnedObject(), IntPtr.Zero); }
public SessionListener() { _sessionLost = new InternalSessionLost(_SessionLost); _sessionMemberAdded = new InternalSessionMemberAdded(_SessionMemberAdded); _sessionMemberRemoved = new InternalSessionMemberRemoved(_SessionMemberRemoved); #if UNITY_ANDROID _sessionListener = alljoyn_unitysessionlistener_create(this, _sessionLost, _sessionMemberAdded, _sessionMemberRemoved); #else SessionListenerCallbacks callbacks; callbacks.sessionLost = Marshal.GetFunctionPointerForDelegate(_sessionLost); callbacks.sessionMemberAdded = Marshal.GetFunctionPointerForDelegate(_sessionMemberAdded); callbacks.sessionMemberRemoved = Marshal.GetFunctionPointerForDelegate(_sessionMemberRemoved); GCHandle gch = GCHandle.Alloc(callbacks, GCHandleType.Pinned); _sessionListener = alljoyn_sessionlistener_create(gch.AddrOfPinnedObject(), IntPtr.Zero); gch.Free(); #endif }