Esempio n. 1
0
 public override void onIo(MamaIo io, mamaIoType ioType)
 {
     if (!example_.quiet)
     {
         Console.WriteLine("EXCEPT");
     }
 }
Esempio n. 2
0
            public override void onIo(MamaIo io, mamaIoType ioType)
            {
                Socket sock = example_.client;

                byte [] buffer = new byte[1024];
                int     len    = sock.Receive(buffer, 1023, SocketFlags.None);

                buffer[len] = (byte)'\0';

                string text = Encoding.ASCII.GetString(buffer, 0, len);

                if (!example_.quiet)
                {
                    Console.WriteLine("READ: {0}", text);
                }

                // should test for "quit", but Windows' telnet client won't send it
                // no matter if "set mode stream" was used and would send only partial
                // substrings, such as "q", then "uit", "qu", then "it", etc.
                if (text.StartsWith("q"))
                {
                    Console.WriteLine("QUITING");
                    Mama.stop(MamaIoCS.bridge);
                    return;
                }

                sock.Send(buffer, len, SocketFlags.None);
            }
Esempio n. 3
0
        /// <summary>
        /// Create an IO handler.
        /// </summary>
        /// <remarks>
        /// If the underlying infrastructure does not support the requested mamaIoType,
        /// create throws MamaException(MAMA_STATUS_UNSUPPORTED_IO_TYPE). For example,
        /// RV only supports READ, WRITE, and EXCEPT. LBM supports all types except ERROR
        /// </remarks>
        /// <param name="queue">The event queue for the io events. null specifies the
        /// Mama default queue</param>
        /// <param name="action">The callback to be invoked when an event occurs.</param>
        /// <param name="descriptor">Wait for IO on this descriptor.</param>
        /// <param name="ioType">Wait for occurences of this type.</param>
        /// <param name="closure">The closure that is passed to the callback.</param>
        public void create(
            MamaQueue queue,
            MamaIoCallback action,
            uint descriptor,
            mamaIoType ioType,
            object closure)
        {
#if MAMA_WRAPPERS_CHECK_ARGUMENTS
            if (action == null)
            {
                throw new ArgumentNullException("action");
            }
#endif // MAMA_WRAPPERS_CHECK_ARGUMENTS
            this.callback      = action;
            this.closureObject = closure;

            IntPtr queueHandle = queue != null ? queue.NativeHandle : IntPtr.Zero;
            int    code        = NativeMethods.mamaIo_create(
                ref nativeHandle,
                queueHandle,
                descriptor,
                mIoDelegate,
                (int)ioType,
                IntPtr.Zero);
            CheckResultCode(code);

            GC.KeepAlive(queue);
        }
Esempio n. 4
0
 /// <summary>
 /// CLS compliant version of create
 /// <see cref="create(MamaQueue, MamaIoCallback, uint, mamaIoType, System.Object)"/>
 /// </summary>
 public void create(
     MamaQueue queue,
     MamaIoCallback action,
     long descriptor,
     mamaIoType ioType)
 {
     create(queue, action, descriptor, ioType, null);
 }
Esempio n. 5
0
        /// <summary>
        /// CLS compliant version of create
        /// <see cref="create(MamaQueue, MamaIoCallback, uint, mamaIoType, System.Object)"/>
        /// </summary>
        public void create(
            MamaQueue queue,
            MamaIoCallback action,
            long descriptor,
            mamaIoType ioType,
            object closure)
        {
#if MAMA_WRAPPERS_CHECK_ARGUMENTS
            if (descriptor < 0 || descriptor > UInt32.MaxValue)
            {
                throw new ArgumentOutOfRangeException("descriptor", descriptor);
            }
#endif // MAMA_WRAPPERS_CHECK_ARGUMENTS
            create(queue, action, (uint)descriptor, ioType, closure);
        }
Esempio n. 6
0
 // called too many times, debug output disabled
 public override void onIo(MamaIo io, mamaIoType ioType)
 {
 }
Esempio n. 7
0
 public abstract void onIo(MamaIo io, mamaIoType ioType);
Esempio n. 8
0
		/// <summary>
		/// CLS compliant version of create
		/// <see cref="create(MamaQueue, MamaIoCallback, uint, mamaIoType, System.Object)"/>
		/// </summary>
		public void create(
			MamaQueue queue,
			MamaIoCallback action, 
			long descriptor,
			mamaIoType ioType)
		{
			create(queue, action, descriptor, ioType, null);
		}
Esempio n. 9
0
		/// <summary>
		/// Create an IO handler.
		/// </summary>
		/// <remarks>
		/// If the underlying infrastructure does not support the requested mamaIoType,
		/// create throws MamaException(MAMA_STATUS_UNSUPPORTED_IO_TYPE). For example,
		/// RV only supports READ, WRITE, and EXCEPT. LBM supports all types except ERROR
		/// </remarks>
		/// <param name="queue">The event queue for the io events. null specifies the
		/// Mama default queue</param>
		/// <param name="action">The callback to be invoked when an event occurs.</param>
		/// <param name="descriptor">Wait for IO on this descriptor.</param>
		/// <param name="ioType">Wait for occurences of this type.</param>
		/// <param name="closure">The closure that is passed to the callback.</param>
		public void create(
			MamaQueue queue,
			MamaIoCallback action, 
			uint descriptor,
			mamaIoType ioType,
			object closure)
		{
#if MAMA_WRAPPERS_CHECK_ARGUMENTS
			if (action == null)
			{
				throw new ArgumentNullException("action");
			}
#endif // MAMA_WRAPPERS_CHECK_ARGUMENTS
			this.callback = action;
			this.closureObject = closure;

			IntPtr queueHandle = queue != null ? queue.NativeHandle : IntPtr.Zero;
			int code = NativeMethods.mamaIo_create(
				ref nativeHandle, 
				queueHandle, 
				descriptor, 
				mIoDelegate,
				(int)ioType,
				IntPtr.Zero);
			CheckResultCode(code);
			
			GC.KeepAlive(queue);
		}
Esempio n. 10
0
		/// <summary>
		/// CLS compliant version of create
		/// <see cref="create(MamaQueue, MamaIoCallback, uint, mamaIoType, System.Object)"/>
		/// </summary>
		public void create(
			MamaQueue queue,
			MamaIoCallback action, 
			long descriptor,
			mamaIoType ioType,
			object closure)
		{
#if MAMA_WRAPPERS_CHECK_ARGUMENTS
			if (descriptor < 0 || descriptor > UInt32.MaxValue)
			{
				throw new ArgumentOutOfRangeException("descriptor", descriptor);
			}
#endif // MAMA_WRAPPERS_CHECK_ARGUMENTS
			create(queue, action, (uint)descriptor, ioType, closure);
		}
Esempio n. 11
0
			public override void onIo(MamaIo io, mamaIoType ioType)
			{
				if (!example_.quiet)
				{
					Console.WriteLine("EXCEPT");
				}
			}
Esempio n. 12
0
			// called too many times, debug output disabled
			public override void onIo(MamaIo io, mamaIoType ioType)
			{
			}
Esempio n. 13
0
			public override void onIo(MamaIo io, mamaIoType ioType)
			{
				Socket sock = example_.client;

				byte [] buffer = new byte[1024];
				int len = sock.Receive(buffer, 1023, SocketFlags.None);
				buffer[len] = (byte)'\0';

				string text = Encoding.ASCII.GetString(buffer, 0, len);
				if (!example_.quiet)
				{
					Console.WriteLine("READ: {0}", text);
				}

				// should test for "quit", but Windows' telnet client won't send it
				// no matter if "set mode stream" was used and would send only partial
				// substrings, such as "q", then "uit", "qu", then "it", etc.
				if (text.StartsWith("q"))
				{
					Console.WriteLine("QUITING");
					Mama.stop(MamaIoCS.bridge);
					return;
				}

				sock.Send(buffer, len, SocketFlags.None);
			}
Esempio n. 14
0
			public abstract void onIo(MamaIo io, mamaIoType ioType);