コード例 #1
0
ファイル: CaptureLogic.cs プロジェクト: Gavvers/GameLogger
        public async void stopCapture(PendingMessageCallback callback = null)
        {
            Trace.Assert(captureState == CaptureState.Capturing &&
                attachState == AttachState.Attached, "Must be attached before capturing");
            Log.Info("stopping data capture from process {0}", currentProcess);

            DllMessageStopCapture msg = DllMessage.Factory.Create(DllMessageType.STOP_CAPTURE) as DllMessageStopCapture;

            msg.reason = DllMessageStopCapture.DllMessageStopCaptureReason.UserRequest;

            await Task.Factory.StartNew(() =>
            {
                if (callback != null)
                    pendingMessageCallback = callback;

                notifyEvent(EventNotification.CaptureStopping);
                pendingMessageState = PendingMessageState.StopCaptureSent;

                pipeServer.writeMessage(DllMessage.Factory.Encode(msg).data, (result) =>
                {
                    if (!result)
                        return;
                }, TimeSpan.FromMilliseconds(1000));
            });
        }
コード例 #2
0
ファイル: CaptureLogic.cs プロジェクト: Gavvers/GameLogger
        private void handleMessage(DllMessage msg)
        {
            if(msg.type != DllMessageType.NEW_RECORDS)
                Log.Info("Got message of type " + msg.type.ToString());

            switch (msg.type)
            {
                case DllMessageType.NEW_RECORDS:
                {
                    DllMessageNewRecords m = msg as DllMessageNewRecords;

                    OnNewRecord(m.records);

                    break;
                }
                case DllMessageType.START_CAPTURE_RESP:
                {
                    if (pendingMessageState != PendingMessageState.StartCaptureSent)
                    {
                        Log.Error("Unexpected message in current state {0}", pendingMessageState);
                        break;
                    }

                    DllMessageStartCaptureResp m = msg as DllMessageStartCaptureResp;

                    if (m.okay)
                    {
                        Log.Info("DLL confirms capture start");

                        captureState = CaptureState.Capturing;
                        notifyEvent(EventNotification.CaptureStarted);
                    }

                    if (pendingMessageCallback != null)
                    {
                        pendingMessageCallback(EventNotification.CaptureStarted, m.okay);
                        pendingMessageCallback = null;
                    }

                    pendingMessageState = PendingMessageState.Attached;
                    break;
                }
                case DllMessageType.STOP_CAPTURE_RESP:
                {
                    if (pendingMessageState != PendingMessageState.StopCaptureSent)
                    {
                        Log.Error("Unexpected message in current state {0}", pendingMessageState);
                        break;
                    }

                    DllMessageStopCaptureResp m = msg as DllMessageStopCaptureResp;

                    if (m.okay)
                    {
                        Log.Info("DLL confirms capture stop");

                        captureState = CaptureState.NotCapturing;
                        notifyEvent(EventNotification.CaptureStopped);
                    }

                    if (pendingMessageCallback != null)
                    {
                        pendingMessageCallback(EventNotification.CaptureStopped, m.okay);
                        pendingMessageCallback = null;
                    }

                    pendingMessageState = PendingMessageState.Attached;
                    break;
                }
                case DllMessageType.SCREENDATA:
                {
                        DllMessageScreendata m = msg as DllMessageScreendata;

                        Log.Info("Got screendata of size {0}", m.data.Count);

                        File.WriteAllBytes("test-screenshot.tga", m.data.ToArray());
                        break;
                }
            }
        }
コード例 #3
0
ファイル: CaptureLogic.cs プロジェクト: Gavvers/GameLogger
        public async void capture()
        {
            Trace.Assert(captureState == CaptureState.NotCapturing &&
                attachState == AttachState.Attached, "Must be attached and not capturing already before capturing");
            Log.Info("capturing data from process {0}", currentProcess);

            DllMessageStartCapture msg = DllMessage.Factory.Create(DllMessageType.START_CAPTURE) as DllMessageStartCapture;

            msg.reason = DllMessageStartCapture.DllMessageStartCaptureReason.UserRequest;

            await Task.Factory.StartNew(() =>
            {
                pendingMessageState = PendingMessageState.StartCaptureSent;
                notifyEvent(EventNotification.CaptureStarting);

                pipeServer.writeMessage(DllMessage.Factory.Encode(msg).data, (result) =>
                {
                    if (!result)
                        return;
                }, TimeSpan.FromMilliseconds(1000));
            });
        }