Пример #1
0
        private bool Initialize(Action <CaptureEngine> created, CaptureEngine engine)
        {
            this.createdHandler = (handle, result, message) =>
            {
                this.Handle = handle;

                if (this.Handle == Plugin.InvalidHandle)
                {
                    engine.Close();
                    engine.Dispose();
                    engine = null;
                }

                created(engine);
            };
            this.createdCallbackHandle = GCHandle.Alloc(this.createdHandler);

            this.startedHandler        = this.OnStarted;
            this.startedCallbackHandle = GCHandle.Alloc(this.startedHandler);

            this.stoppedHandler        = this.OnStopped;
            this.stoppedCallbackHandle = GCHandle.Alloc(this.stoppedHandler);

            return(Wrapper.exCreate(false, this.createdHandler) == 0);
        }
        private void OnCaptureInitialized(CaptureEngine engine)
        {
            this.plugin.QueueAction(() =>
            {
                this.CaptureState = CaptureState.Initialized;

                CaptureInitialized(engine);
            });
        }
        private void CaptureInitialized(CaptureEngine engine)
        {
            this.captureEngine = engine;
            if (this.captureEngine != null)
            {
                this.CaptureStart();
            }

            if (this.captureState != CaptureState.Starting)
            {
                this.CaptureState = CaptureState.Failed;

                this.Shutdown();
            }
        }
        private void CaptureClosed()
        {
            if (this.captureEngine != null)
            {
                this.captureEngine.Closed -= this.OnCaptureClosed;
                this.captureEngine.Dispose();
            }
            this.captureEngine = null;

            if (this.captureState != CaptureState.Closed)
            {
                this.CaptureState = CaptureState.Failed;
            }

            Shutdown();
        }
Пример #5
0
        public static bool Create(Action <CaptureEngine> created)
        {
            if (created == null)
            {
                return(false);
            }

            CaptureEngine engine = new CaptureEngine();

            if (engine == null)
            {
                return(false);
            }

            if (!engine.Initialize(created, engine))
            {
                return(false);
            }

            return(true);
        }
        private void CaptureInitialize(Connection connection)
        {
            if (connection == null)
            {
                return;
            }

            this.networkConnection = connection;
            this.networkConnection.Disconnected += this.OnDisconnected;
            this.networkConnection.Closed       += this.OnConnectionClosed;
            this.ConnectionState = ConnectionState.Connected;

            if (CaptureEngine.Create(this.OnCaptureInitialized))
            {
                this.CaptureState = CaptureState.Initializing;
            }
            else
            {
                this.CaptureState = CaptureState.Failed;

                Shutdown();
            }
        }