public abstract class AbstractExProtoHandler extends ExProto
Connection java project to EMQ X Broker. Note 1: Not use "System.in.*" or "System.out.*" They are used to communicate with EMQ X. Note 2: Invoke "ExProtoSDK.loadExProtoHandler(AbstractExProtoHandler handler)" or "AbstractExProtoHandler.loadExProtoHandler(AbstractExProtoHandler handler)"
load your AbstractExProtoHandler in the "Nonparametric construction method".
| Constructor and Description |
|---|
AbstractExProtoHandler() |
| Modifier and Type | Method and Description |
|---|---|
abstract void |
onConnectionDeliver(Connection connection,
Message[] messagesArr)
A connection received a serial of messages from subscribed topic.
|
abstract void |
onConnectionEstablished(Connection connection,
ConnectionInfo connectionInfo)
A connection established.
|
abstract void |
onConnectionReceived(Connection connection,
byte[] data)
A connection received bytes.
|
abstract void |
onConnectionTerminated(Connection connection,
String reason)
A connection terminated.
|
static void |
publish(Connection connection,
Message message)
The connection Publish a Message to EMQ X
|
static void |
register(Connection connection,
ClientInfo clientInfo)
Register the connection as a Client of EMQ X.
|
static void |
send(Connection connection,
byte[] data)
Send a stream of bytes to the connection.
|
static void |
subscribe(Connection connection,
String topic,
int qos)
The connection Subscribe a Topic to EMQ X
|
static void |
terminate(Connection connection)
Terminate the connection process and TCP/UDP socket.
|
static void |
unsubscribe(Connection connection,
String topic)
The Connection UnSubscribe a Topic to EMQ X
|
deliver, init, loadExProtoHandler, received, terminatedpublic abstract void onConnectionEstablished(Connection connection, ConnectionInfo connectionInfo)
This function will be scheduled after a TCP connection established to EMQ X or receive a new UDP socket.
connection - The Connection instanceconnectionInfo - The Connection informationpublic abstract void onConnectionReceived(Connection connection, byte[] data)
This callback will be scheduled when a connection received bytes from TCP/UDP socket.
connection - The Connection instancedata - The bytes arraypublic abstract void onConnectionTerminated(Connection connection, String reason)
This function will be scheduled after a connection terminated.
It indicates that the EMQ X process that maintains the TCP/UDP socket has been closed. E.g: a TCP connection is closed, or a UDP socket has exceeded maintenance hours.
connection - The Connection instancereason - The Connection terminated reasonpublic abstract void onConnectionDeliver(Connection connection, Message[] messagesArr)
This function will be scheduled when a connection received a Message from EMQ X
When a connection is subscribed to a topic and a message arrives on that topic, EMQ X will deliver the message to that connection. At that time, this function is triggered.
connection - The Connection instancemessagesArr - The message arraypublic static void send(Connection connection, byte[] data) throws Exception
These bytes are delivered directly to the associated TCP/UDP socket.
connection - The Connection instancedata - The bytesExceptionpublic static void terminate(Connection connection) throws Exception
connection - The Connection instanceExceptionpublic static void register(Connection connection, ClientInfo clientInfo) throws Exception
This `clientInfo` contains the necessary field information to be an EMQ X client.
This method should normally be invoked after confirming that a connection is allowed to access the EMQ X system. For example: after the connection packet has been parsed and authenticated successfully.
connection - Then Connection instanceclientInfo - The Client informationExceptionpublic static void publish(Connection connection, Message message) throws Exception
connection - The Connection instancemessage - The MessageExceptionpublic static void subscribe(Connection connection, String topic, int qos) throws Exception
connection - The Connection instancetopic - The Topic name.qos - The subscribed QoS level, available value: 0, 1, 2.Exceptionpublic static void unsubscribe(Connection connection, String topic) throws Exception
connection - The Connection instancetopic - The Topic name.ExceptionCopyright © 2020. All rights reserved.