public void OnMessage(int msgTypeId, IMutableDirectBuffer buffer, int index, int length) { switch (msgTypeId) { case ControlProtocolEvents.ON_ERROR: { _errorResponse.Wrap(buffer, index); int correlationId = (int) _errorResponse.OffendingCommandCorrelationId(); int errorCodeValue = _errorResponse.ErrorCodeValue(); var errorCode = GetErrorCode(_errorResponse.ErrorCodeValue()); var message = _errorResponse.ErrorMessage(); if (ErrorCode.CHANNEL_ENDPOINT_ERROR == errorCode) { _listener.OnChannelEndpointError(correlationId, message); } else if (correlationId == _activeCorrelationId) { _receivedCorrelationId = correlationId; _listener.OnError(correlationId, errorCodeValue, errorCode, message); } break; } case ControlProtocolEvents.ON_AVAILABLE_IMAGE: { _imageReady.Wrap(buffer, index); _listener.OnAvailableImage( _imageReady.CorrelationId(), _imageReady.StreamId(), _imageReady.SessionId(), _imageReady.SubscriptionRegistrationId(), _imageReady.SubscriberPositionId(), _imageReady.LogFileName(), _imageReady.SourceIdentity()); break; } case ControlProtocolEvents.ON_PUBLICATION_READY: { _publicationReady.Wrap(buffer, index); long correlationId = _publicationReady.CorrelationId(); if (correlationId == _activeCorrelationId) { _receivedCorrelationId = correlationId; _listener.OnNewPublication( correlationId, _publicationReady.RegistrationId(), _publicationReady.StreamId(), _publicationReady.SessionId(), _publicationReady.PublicationLimitCounterId(), _publicationReady.ChannelStatusCounterId(), _publicationReady.LogFileName()); } break; } case ControlProtocolEvents.ON_SUBSCRIPTION_READY: { _subscriptionReady.Wrap(buffer, index); long correlationId = _subscriptionReady.CorrelationId(); if (correlationId == _activeCorrelationId) { _receivedCorrelationId = correlationId; _listener.OnNewSubscription(correlationId, _subscriptionReady.ChannelStatusCounterId()); } break; } case ControlProtocolEvents.ON_OPERATION_SUCCESS: { _operationSucceeded.Wrap(buffer, index); long correlationId = _operationSucceeded.CorrelationId(); if (correlationId == _activeCorrelationId) { _receivedCorrelationId = correlationId; } break; } case ControlProtocolEvents.ON_UNAVAILABLE_IMAGE: { _imageMessage.Wrap(buffer, index); _listener.OnUnavailableImage( _imageMessage.CorrelationId(), _imageMessage.SubscriptionRegistrationId(), _imageMessage.StreamId()); break; } case ControlProtocolEvents.ON_EXCLUSIVE_PUBLICATION_READY: { _publicationReady.Wrap(buffer, index); long correlationId = _publicationReady.CorrelationId(); if (correlationId == _activeCorrelationId) { _receivedCorrelationId = correlationId; _listener.OnNewExclusivePublication( correlationId, _publicationReady.RegistrationId(), _publicationReady.StreamId(), _publicationReady.SessionId(), _publicationReady.PublicationLimitCounterId(), _publicationReady.ChannelStatusCounterId(), _publicationReady.LogFileName()); } break; } case ControlProtocolEvents.ON_COUNTER_READY: { _counterUpdate.Wrap(buffer, index); int counterId = _counterUpdate.CounterId(); long correlationId = _counterUpdate.CorrelationId(); if (correlationId == _activeCorrelationId) { _receivedCorrelationId = correlationId; _listener.OnNewCounter(correlationId, counterId); } else { _listener.OnAvailableCounter(correlationId, counterId); } break; } case ControlProtocolEvents.ON_UNAVAILABLE_COUNTER: { _counterUpdate.Wrap(buffer, index); _listener.OnUnavailableCounter(_counterUpdate.CorrelationId(), _counterUpdate.CounterId()); break; } } }
public void OnMessage(int msgTypeId, IMutableDirectBuffer buffer, int index, int length) { switch (msgTypeId) { case ControlProtocolEvents.ON_ERROR: { _errorResponse.Wrap(buffer, index); long correlationId = _errorResponse.OffendingCommandCorrelationId(); if (correlationId == _activeCorrelationId) { _listener.OnError(correlationId, _errorResponse.ErrorCode(), _errorResponse.ErrorMessage()); _lastReceivedCorrelationId = correlationId; } break; } case ControlProtocolEvents.ON_AVAILABLE_IMAGE: { _imageReady.Wrap(buffer, index); _listener.OnAvailableImage( _imageReady.CorrelationId(), _imageReady.StreamId(), _imageReady.SessionId(), _imageReady.SubscriberRegistrationId(), _imageReady.SubscriberPositionId(), _imageReady.LogFileName(), _imageReady.SourceIdentity()); break; } case ControlProtocolEvents.ON_PUBLICATION_READY: { _publicationReady.Wrap(buffer, index); long correlationId = _publicationReady.CorrelationId(); if (correlationId == _activeCorrelationId) { _listener.OnNewPublication( correlationId, _publicationReady.RegistrationId(), _publicationReady.StreamId(), _publicationReady.SessionId(), _publicationReady.PublicationLimitCounterId(), _expectedChannel, _publicationReady.LogFileName()); _lastReceivedCorrelationId = correlationId; } break; } case ControlProtocolEvents.ON_OPERATION_SUCCESS: { _correlatedMessage.Wrap(buffer, index); long correlationId = _correlatedMessage.CorrelationId(); if (correlationId == _activeCorrelationId) { _lastReceivedCorrelationId = correlationId; } break; } case ControlProtocolEvents.ON_UNAVAILABLE_IMAGE: { _imageMessage.Wrap(buffer, index); _listener.OnUnavailableImage(_imageMessage.CorrelationId(), _imageMessage.StreamId()); break; } case ControlProtocolEvents.ON_EXCLUSIVE_PUBLICATION_READY: { _publicationReady.Wrap(buffer, index); long correlationId = _publicationReady.CorrelationId(); if (correlationId == _activeCorrelationId) { _listener.OnNewExclusivePublication( correlationId, _publicationReady.RegistrationId(), _publicationReady.StreamId(), _publicationReady.SessionId(), _publicationReady.PublicationLimitCounterId(), _expectedChannel, _publicationReady.LogFileName()); _lastReceivedCorrelationId = correlationId; } break; } } }