2016-03-03 16:08:52 -08:00
|
|
|
/*
|
2017-01-04 14:37:29 +01:00
|
|
|
* Copyright (c) 2012-2017 The original author or authorsgetRockQuestions()
|
2016-03-03 16:08:52 -08:00
|
|
|
* ------------------------------------------------------
|
|
|
|
|
* All rights reserved. This program and the accompanying materials
|
|
|
|
|
* are made available under the terms of the Eclipse Public License v1.0
|
|
|
|
|
* and Apache License v2.0 which accompanies this distribution.
|
|
|
|
|
*
|
|
|
|
|
* The Eclipse Public License is available at
|
|
|
|
|
* http://www.eclipse.org/legal/epl-v10.html
|
|
|
|
|
*
|
|
|
|
|
* The Apache License v2.0 is available at
|
|
|
|
|
* http://www.opensource.org/licenses/apache2.0.php
|
|
|
|
|
*
|
|
|
|
|
* You may elect to redistribute this code under either of these licenses.
|
|
|
|
|
*/
|
|
|
|
|
package io.moquette.interception;
|
|
|
|
|
|
2017-01-28 10:06:30 +01:00
|
|
|
import io.moquette.interception.messages.*;
|
2016-03-03 16:08:52 -08:00
|
|
|
import io.moquette.spi.impl.subscriptions.Subscription;
|
2017-01-28 10:06:30 +01:00
|
|
|
import io.netty.handler.codec.mqtt.MqttMessage;
|
2016-03-03 16:08:52 -08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This interface is used to inject code for intercepting broker events.
|
|
|
|
|
* <p>
|
|
|
|
|
* The events can act only as observers.
|
|
|
|
|
* <p>
|
2017-01-28 10:06:30 +01:00
|
|
|
* Almost every method receives a subclass of {@link MqttMessage}, except
|
2016-03-03 16:08:52 -08:00
|
|
|
* <code>onDisconnect</code> that receives the client id string and
|
|
|
|
|
* <code>onSubscribe</code> and <code>onUnsubscribe</code> that receive a
|
|
|
|
|
* {@link Subscription} object.
|
|
|
|
|
*
|
|
|
|
|
* @author Wagner Macedo
|
|
|
|
|
*/
|
|
|
|
|
public interface InterceptHandler {
|
2017-01-10 17:06:13 +01:00
|
|
|
|
|
|
|
|
public static final Class<?> ALL_MESSAGE_TYPES[] = { InterceptConnectMessage.class,
|
|
|
|
|
InterceptDisconnectMessage.class, InterceptConnectionLostMessage.class, InterceptPublishMessage.class,
|
|
|
|
|
InterceptSubscribeMessage.class, InterceptUnsubscribeMessage.class, InterceptAcknowledgedMessage.class };
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the identifier of this intercept handler.
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
String getID();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the InterceptMessage subtypes that this handler can process. If the result is null or equal to ALL_MESSAGE_TYPES,
|
|
|
|
|
* all the message types will be processed.
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
Class<?>[] getInterceptedMessageTypes();
|
|
|
|
|
|
2016-03-03 16:08:52 -08:00
|
|
|
void onConnect(InterceptConnectMessage msg);
|
|
|
|
|
|
|
|
|
|
void onDisconnect(InterceptDisconnectMessage msg);
|
|
|
|
|
|
2016-10-21 10:28:36 +08:00
|
|
|
void onConnectionLost(InterceptConnectionLostMessage msg);
|
|
|
|
|
|
2016-03-03 16:08:52 -08:00
|
|
|
void onPublish(InterceptPublishMessage msg);
|
|
|
|
|
|
|
|
|
|
void onSubscribe(InterceptSubscribeMessage msg);
|
|
|
|
|
|
|
|
|
|
void onUnsubscribe(InterceptUnsubscribeMessage msg);
|
|
|
|
|
|
2016-03-04 09:38:17 -08:00
|
|
|
void onMessageAcknowledged(InterceptAcknowledgedMessage msg);
|
2016-03-03 16:08:52 -08:00
|
|
|
}
|