Exemplo n.º 1
0
            /* ************************************************************** */
            #region Construction and Finalization

            /// <summary>
            /// Constructor initialises all member variables.
            /// </summary>
            /// <param name="callback">
            /// The user callback implementation.
            /// </param>
            /// <param name="closure">
            /// The closure supplied to the MamaInbox.create function.
            /// </param>
            /// <param name="inbox">
            /// The actual C# inbox object.
            /// </param>
            internal MamaInboxImpl(MamaInboxCallback callback, object closure, MamaInbox inbox)
            {
                // Save arguments in member variables
                mCallback = callback;
                mClosure  = closure;
                mInbox    = inbox;
            }
Exemplo n.º 2
0
            /* ************************************************************** */
            #region Internal Operations

            /// <summary>
            /// This function creates a new impl and returns an IntPtr that can then be passed to
            /// the native layer.
            /// </summary>
            /// <param name="callback">
            /// The user callback implementation.
            /// </param>
            /// <param name="closure">
            /// The closure supplied to the MamaInbox.create function.
            /// </param>
            /// <param name="inbox">
            /// The actual C# inbox object.
            /// </param>
            /// <returns>
            /// The IntPtr that can then be used for the closure.
            /// </returns>
            internal static IntPtr Create(MamaInboxCallback callback, object closure, MamaInbox inbox)
            {
                // Allocate a new impl
                MamaInboxImpl impl = new MamaInboxImpl(callback, closure, inbox);

                // Create a GC handle
                GCHandle handle = GCHandle.Alloc(impl);

                // Return the native pointer
                return((IntPtr)handle);
            }
Exemplo n.º 3
0
        /* ************************************************************** */
        #region Public Functions

        /// <summary>
        /// Creates an inbox and stores at the address specified by the calling client.
        /// </summary>
        /// <param name="transport">
        /// The mamaTransport being used.
        /// </param>
        /// <param name="queue">
        /// Optional mamaQueue. Will use default queue if null.
        /// </param>
        /// <param name="callback">
        /// A callback interface invoked in response to a p2p message being received or when an error is
        /// encountered during p2p messaging.
        /// </param>
        /// <param name="closure">
        /// User supplied data
        /// </param>
        public void create(MamaTransport transport, MamaQueue queue, MamaInboxCallback callback, object closure)
        {
            // Check the arguments
            if (transport == null)
            {
                throw new ArgumentNullException("transport");
            }

            if (queue == null)
            {
                throw new ArgumentNullException("queue");
            }

            if (callback == null)
            {
                throw new ArgumentNullException("callback");
            }

            // Save the clousre in the member variable
            mClosure = closure;

            // Create the impl
            IntPtr impl = MamaInboxImpl.Create(callback, closure, this);

            /* Create the inbox, register for the destroy callback regardless if the client wants it or not,
             * this is to allow clean-up to be done whenever the inbox has been fully destroyed.
             */
            IntPtr nativeInbox = IntPtr.Zero;

            CheckResultCode(NativeMethods.mamaInbox_create2(
                                ref nativeInbox,
                                transport.NativeHandle,
                                queue.NativeHandle,
                                mMsgDelegate,
                                mErrorDelegate,
                                mDestroyDelegate,
                                impl));

            // Save the native timer in the member variable
            NativeHandle = nativeInbox;
        }
Exemplo n.º 4
0
 /// <summary>
 /// Creates an inbox and stores at the address specified by the calling client.
 /// Uses a default queue.
 /// This functionality is no longer supported.
 /// </summary>
 /// <param name="transport">
 /// The mamaTransport being used.
 /// </param>
 /// <param name="callback">
 /// A callback interface invoked in response to a p2p message being received or hen an error is
 /// encountered during p2p messaging.
 /// </param>
 /// <param name="closure">
 /// User supplied data.
 /// </param>
 public void create(MamaTransport transport, MamaInboxCallback callback, object closure)
 {
     throw new NotSupportedException("This function is no longer supported, use an overload that takes a MamaQueue object.");
 }
Exemplo n.º 5
0
 /// <summary>
 /// Creates an inbox and stores at the address specified by the calling client.
 /// </summary>
 /// <param name="transport">
 /// The mamaTransport being used.
 /// </param>
 /// <param name="queue">
 /// Optional mamaQueue. Will use default queue if null.
 /// </param>
 /// <param name="callback">
 /// A callback interface invoked in response to a p2p message being received or when an error is
 /// encountered during p2p messaging.
 /// </param>
 public void create(MamaTransport transport, MamaQueue queue, MamaInboxCallback callback)
 {
     create(transport, queue, callback, null);
 }
Exemplo n.º 6
0
		/// <summary>
		/// Creates an inbox and stores at the address specified by the calling client.
		/// Uses a default queue.
        /// This functionality is no longer supported.
		/// </summary>
		/// <param name="transport">
        /// The mamaTransport being used.
        /// </param>
		/// <param name="callback">
        /// A callback interface invoked in response to a p2p message being received or hen an error is 
        /// encountered during p2p messaging.
        /// </param>		
        /// <param name="closure">
        /// User supplied data.
        /// </param>
		public void create(MamaTransport transport, MamaInboxCallback callback, object closure)
		{
            throw new NotSupportedException("This function is no longer supported, use an overload that takes a MamaQueue object.");			
		}
Exemplo n.º 7
0
		/// <summary>
		/// Creates an inbox and stores at the address specified by the calling client.
		/// </summary>
		/// <param name="transport">
        /// The mamaTransport being used.
        /// </param>
		/// <param name="queue">
        /// Optional mamaQueue. Will use default queue if null.
        /// </param>
		/// <param name="callback">
        /// A callback interface invoked in response to a p2p message being received or when an error is 
        /// encountered during p2p messaging.
        /// </param>
		public void create(MamaTransport transport, MamaQueue queue, MamaInboxCallback callback)
		{
			create(transport, queue, callback, null);
		}
Exemplo n.º 8
0
        /* ************************************************************** */
        #region Public Functions

        /// <summary>
		/// Creates an inbox and stores at the address specified by the calling client.
		/// </summary>
		/// <param name="transport">
        /// The mamaTransport being used.
        /// </param>
		/// <param name="queue">
        /// Optional mamaQueue. Will use default queue if null.
        /// </param>
		/// <param name="callback">
        /// A callback interface invoked in response to a p2p message being received or when an error is 
        /// encountered during p2p messaging.
        /// </param>
		/// <param name="closure">
        /// User supplied data
        /// </param>
		public void create(MamaTransport transport, MamaQueue queue, MamaInboxCallback callback, object closure)
		{
            // Check the arguments
			if (transport == null)
			{
				throw new ArgumentNullException("transport");
			}

            if(queue == null)
            {
                throw new ArgumentNullException("queue");
            }

			if (callback == null)
			{
				throw new ArgumentNullException("callback");
			}

            // Save the clousre in the member variable
            mClosure = closure;

            // Create the impl
            IntPtr impl = MamaInboxImpl.Create(callback, closure, this);

            /* Create the inbox, register for the destroy callback regardless if the client wants it or not,
             * this is to allow clean-up to be done whenever the inbox has been fully destroyed.
             */
            IntPtr nativeInbox = IntPtr.Zero;
            CheckResultCode(NativeMethods.mamaInbox_create2(
                ref nativeInbox,
                transport.NativeHandle,
                queue.NativeHandle,
                mMsgDelegate,
                mErrorDelegate,
                mDestroyDelegate,                
                impl));

            // Save the native timer in the member variable
            NativeHandle = nativeInbox;
		}
Exemplo n.º 9
0
            /* ************************************************************** */
            #region Internal Operations

            /// <summary>
            /// This function creates a new impl and returns an IntPtr that can then be passed to
            /// the native layer.
            /// </summary>
            /// <param name="callback">
            /// The user callback implementation.
            /// </param>
            /// <param name="closure">
            /// The closure supplied to the MamaInbox.create function.
            /// </param>
            /// <param name="inbox">
            /// The actual C# inbox object.
            /// </param>
            /// <returns>
            /// The IntPtr that can then be used for the closure.
            /// </returns>
            internal static IntPtr Create(MamaInboxCallback callback, object closure, MamaInbox inbox)
            {
                // Allocate a new impl
                MamaInboxImpl impl = new MamaInboxImpl(callback, closure, inbox);

                // Create a GC handle
                GCHandle handle = GCHandle.Alloc(impl);

                // Return the native pointer
                return (IntPtr)handle;
            }
Exemplo n.º 10
0
            /* ************************************************************** */
            #region Construction and Finalization

            /// <summary>
            /// Constructor initialises all member variables.
            /// </summary>
            /// <param name="callback">
            /// The user callback implementation.
            /// </param>
            /// <param name="closure">
            /// The closure supplied to the MamaInbox.create function.
            /// </param>
            /// <param name="inbox">
            /// The actual C# inbox object.
            /// </param>
            internal MamaInboxImpl(MamaInboxCallback callback, object closure, MamaInbox inbox)
            {
                // Save arguments in member variables
                mCallback  = callback;
                mClosure   = closure;
                mInbox     = inbox;
            }