コード例 #1
0
        public virtual void OnFragment(IDirectBuffer buffer, int offset, int length, Header header)
        {
            messageHeaderDecoder.Wrap(buffer, offset);

            int templateId = messageHeaderDecoder.TemplateId();

            switch (templateId)
            {
            case RecordingStartedDecoder.TEMPLATE_ID:
                recordingStartedDecoder.Wrap(buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version());

                listener.OnStart(recordingStartedDecoder.RecordingId(), recordingStartedDecoder.StartPosition(), recordingStartedDecoder.SessionId(), recordingStartedDecoder.StreamId(), recordingStartedDecoder.Channel(), recordingStartedDecoder.SourceIdentity());
                break;

            case RecordingProgressDecoder.TEMPLATE_ID:
                recordingProgressDecoder.Wrap(buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version());

                listener.OnProgress(recordingProgressDecoder.RecordingId(), recordingProgressDecoder.StartPosition(), recordingProgressDecoder.Position());
                break;

            case RecordingStoppedDecoder.TEMPLATE_ID:
                recordingStoppedDecoder.Wrap(buffer, offset + MessageHeaderDecoder.ENCODED_LENGTH, messageHeaderDecoder.BlockLength(), messageHeaderDecoder.Version());

                listener.OnStop(recordingStoppedDecoder.RecordingId(), recordingStoppedDecoder.StartPosition(), recordingStoppedDecoder.StopPosition());
                break;

            default:
                throw new System.InvalidOperationException("Unknown templateId: " + templateId);
            }
        }
コード例 #2
0
        public void OnFragment(IDirectBuffer buffer, int offset, int length, Header header)
        {
            _messageHeaderDecoder.Wrap(buffer, offset);

            int schemaId = _messageHeaderDecoder.SchemaId();

            if (schemaId != MessageHeaderDecoder.SCHEMA_ID)
            {
                throw new ArchiveException("expected schemaId=" + MessageHeaderDecoder.SCHEMA_ID + ", actual=" +
                                           schemaId);
            }

            int templateId = _messageHeaderDecoder.TemplateId();

            switch (templateId)
            {
            case RecordingStartedDecoder.TEMPLATE_ID:
                _recordingStartedDecoder.Wrap(
                    buffer,
                    offset + MessageHeaderDecoder.ENCODED_LENGTH,
                    _messageHeaderDecoder.BlockLength(),
                    _messageHeaderDecoder.Version());

                _listener.OnStart(
                    _recordingStartedDecoder.RecordingId(),
                    _recordingStartedDecoder.StartPosition(),
                    _recordingStartedDecoder.SessionId(),
                    _recordingStartedDecoder.StreamId(),
                    _recordingStartedDecoder.Channel(),
                    _recordingStartedDecoder.SourceIdentity());
                break;

            case RecordingProgressDecoder.TEMPLATE_ID:
                _recordingProgressDecoder.Wrap(
                    buffer,
                    offset + MessageHeaderDecoder.ENCODED_LENGTH,
                    _messageHeaderDecoder.BlockLength(),
                    _messageHeaderDecoder.Version());

                _listener.OnProgress(
                    _recordingProgressDecoder.RecordingId(),
                    _recordingProgressDecoder.StartPosition(),
                    _recordingProgressDecoder.Position());
                break;

            case RecordingStoppedDecoder.TEMPLATE_ID:
                _recordingStoppedDecoder.Wrap(
                    buffer,
                    offset + MessageHeaderDecoder.ENCODED_LENGTH,
                    _messageHeaderDecoder.BlockLength(),
                    _messageHeaderDecoder.Version());

                _listener.OnStop(
                    _recordingStoppedDecoder.RecordingId(),
                    _recordingStoppedDecoder.StartPosition(),
                    _recordingStoppedDecoder.StopPosition());
                break;
            }
        }