Пример #1
0
        protected virtual void OnCallback(CFStreamEventType type)
        {
            var args = new StreamEventArgs(type);

            switch (type)
            {
            case CFStreamEventType.OpenCompleted:
                OnOpenCompleted(args);
                break;

            case CFStreamEventType.CanAcceptBytes:
                OnCanAcceptBytesEvent(args);
                break;

            case CFStreamEventType.HasBytesAvailable:
                OnHasBytesAvailableEvent(args);
                break;

            case CFStreamEventType.ErrorOccurred:
                OnErrorEvent(args);
                break;

            case CFStreamEventType.EndEncountered:
                OnClosedEvent(args);
                break;
            }
        }
Пример #2
0
        public void Notify(CFStreamEventType eventType)
        {
            if ((flags & eventType) == 0)
                return;

            context.Invoke (callback, Handle, eventType);
        }
Пример #3
0
		internal void Invoke (IntPtr callback, IntPtr stream, CFStreamEventType eventType)
		{
			if (callback == IntPtr.Zero)
				return;

			CFReadStreamRef_InvokeCallback (callback, stream, eventType, Info);
		}
Пример #4
0
        public void Notify(CFStreamEventType eventType)
        {
            if ((flags & eventType) == 0)
            {
                return;
            }

            context.Invoke(callback, Handle, eventType);
        }
Пример #5
0
        internal void Invoke(IntPtr callback, IntPtr stream, CFStreamEventType eventType)
        {
            if (callback == IntPtr.Zero)
            {
                return;
            }

            CFReadStreamRef_InvokeCallback(callback, stream, eventType, Info);
        }
Пример #6
0
		protected virtual bool SetCFClientFlags (CFStreamEventType inFlags, IntPtr inCallback, IntPtr inContextPtr)
		{
			CFStreamClientContext inContext;
			
			if (inContextPtr == IntPtr.Zero)
				return false;
			
			inContext = (CFStreamClientContext) Marshal.PtrToStructure (inContextPtr, typeof (CFStreamClientContext));
			if (inContext.Version != 0)
				return false;
			
			context.Release ();
			context = inContext;
			context.Retain ();
			
			flags = inFlags;
			callback = inCallback;

			return true;
		}
Пример #7
0
        protected virtual bool SetCFClientFlags(CFStreamEventType inFlags, IntPtr inCallback, IntPtr inContextPtr)
        {
            CFStreamClientContext inContext;

            if (inContextPtr == IntPtr.Zero)
            {
                return(false);
            }

            inContext = (CFStreamClientContext)Marshal.PtrToStructure(inContextPtr, typeof(CFStreamClientContext));
            if (inContext.Version != 0)
            {
                return(false);
            }

            context.Release();
            context = inContext;
            context.Retain();

            flags    = inFlags;
            callback = inCallback;

            return(true);
        }
Пример #8
0
 static void OnCallback(IntPtr s, CFStreamEventType type, IntPtr info)
 {
     var stream = GCHandle.FromIntPtr (info).Target as CFStream;
     stream.OnCallback (type);
 }
Пример #9
0
 protected virtual void OnCallback(CFStreamEventType type)
 {
     var args = new StreamEventArgs (type);
     switch (type) {
     case CFStreamEventType.OpenCompleted:
         OnOpenCompleted (args);
         break;
     case CFStreamEventType.CanAcceptBytes:
         OnCanAcceptBytesEvent (args);
         break;
     case CFStreamEventType.HasBytesAvailable:
         OnHasBytesAvailableEvent (args);
         break;
     case CFStreamEventType.ErrorOccurred:
         OnErrorEvent (args);
         break;
     case CFStreamEventType.EndEncountered:
         OnClosedEvent (args);
         break;
     }
 }
Пример #10
0
 static void CFReadStreamRef_InvokeCallback(IntPtr callback, IntPtr stream, CFStreamEventType eventType, IntPtr info)
 {
     ((CallbackDelegate)Marshal.GetDelegateForFunctionPointer (callback, typeof (CallbackDelegate))) (stream, eventType, info);
 }
Пример #11
0
 public StreamEventArgs(CFStreamEventType type)
 {
     this.EventType = type;
 }
Пример #12
0
 static void CFReadStreamRef_InvokeCallback(IntPtr callback, IntPtr stream, CFStreamEventType eventType, IntPtr info)
 {
     ((CallbackDelegate)Marshal.GetDelegateForFunctionPointer(callback, typeof(CallbackDelegate)))(stream, (IntPtr)eventType, info);
 }
Пример #13
0
        static void OnCallback(IntPtr s, CFStreamEventType type, IntPtr info)
        {
            var stream = GCHandle.FromIntPtr(info).Target as CFStream;

            stream.OnCallback(type);
        }
Пример #14
0
		protected override bool SetCFClientFlags (CFStreamEventType inFlags, IntPtr inCallback, IntPtr inContextPtr)
		{
			// Just call the base implementation, which knows how to handle everything.
			return base.SetCFClientFlags (inFlags, inCallback, inContextPtr);
		}
Пример #15
0
 public StreamEventArgs(CFStreamEventType type)
 {
     this.EventType = type;
 }
Пример #16
0
 protected override bool SetCFClientFlags(CFStreamEventType inFlags, IntPtr inCallback, IntPtr inContextPtr)
 {
     // Just call the base implementation, which knows how to handle everything.
     return(base.SetCFClientFlags(inFlags, inCallback, inContextPtr));
 }
Пример #17
0
 public void Notify(CFStreamEventType eventType)
 {
     if ((flags & eventType) == 0)
         return; }