Package org.fisco.bcos.sdk.channel
Interface Channel
- All Known Implementing Classes:
ChannelImp
public interface Channel
The channel module interface.
-
Method Summary
Modifier and Type Method Description void
addConnectHandler(MsgHandler handler)
Add a connect handler, when one connect success, call handler.onConnect(ChannleHandlerContext ctx)is calledvoid
addDisconnectHandler(MsgHandler handler)
Add a disconnect handler, when one connection disconnect, handler.onDisconnect(ChannleHandlerContext ctx) is calledvoid
addEstablishHandler(MsgHandler handler)
Add a establish handler, when the SDK establishes a connection with the node, call the handlervoid
addMessageHandler(MsgType type, MsgHandler handler)
Add a message handler to handle specific type messages.void
asyncSendToPeer(Message out, java.lang.String peerIpPort, ResponseCallback callback, Options options)
Asynchronous interface, send message to peervoid
asyncSendToPeerByRule(Message out, PeerSelectRule rule, ResponseCallback callback, Options options)
Asynchronous interface, send message to peer select by client`s rulevoid
asyncSendToRandom(Message out, ResponseCallback callback, Options options)
Asynchronous interface, send to an random peervoid
broadcast(Message out)
Broadcast to all peer, only sendvoid
broadcastToGroup(Message out, java.lang.String groupId)
Send a message to the given group, only sendstatic Channel
build(ConfigOption configOption)
Init channel modulejava.util.List<java.lang.String>
getAvailablePeer()
Get available peer informationjava.util.List<ConnectionInfo>
getConnectionInfo()
Get connection informationNetwork
getNetwork()
Response
sendToPeer(Message out, java.lang.String peerIpPort)
Synchronize interface, send a message to the given peer, and get the responseResponse
sendToPeerByRuleWithTimeOut(Message out, PeerSelectRule rule, Options options)
Synchronize interface with timeout, send message to peer select by client`s ruleResponse
sendToPeerWithTimeOut(Message out, java.lang.String peerIpPort, Options options)
Synchronize interface with timeout, send a message to the given peer, and get the responseResponse
sendToRandomWithTimeOut(Message out, Options options)
Synchronize interface with timeout, randomly select nodes to send messagesvoid
setThreadPool(java.util.concurrent.ExecutorService threadPool)
void
start()
void
stop()
-
Method Details
-
build
Init channel module- Parameters:
configOption
- config file path.- Returns:
- a channel instance
- Throws:
ConfigException
- the configuration exception
-
getNetwork
Network getNetwork() -
start
void start() -
stop
void stop() -
addMessageHandler
Add a message handler to handle specific type messages. When one message comes the handler will be notified, handler.onMessage(ChannleHandlerContext ctx, Message msg) called.- Parameters:
type
- the type of messagehandler
- the message handler
-
addConnectHandler
Add a connect handler, when one connect success, call handler.onConnect(ChannleHandlerContext ctx)is called- Parameters:
handler
- the connect handler
-
addEstablishHandler
Add a establish handler, when the SDK establishes a connection with the node, call the handler- Parameters:
handler
- the establish handler
-
addDisconnectHandler
Add a disconnect handler, when one connection disconnect, handler.onDisconnect(ChannleHandlerContext ctx) is called- Parameters:
handler
- disconnect handler
-
broadcastToGroup
Send a message to the given group, only send- Parameters:
out
- Message to be sentgroupId
- ID of the group receiving the message packet
-
broadcast
Broadcast to all peer, only send- Parameters:
out
- Message to be sent
-
sendToPeer
Synchronize interface, send a message to the given peer, and get the response- Parameters:
out
- Message to be sentpeerIpPort
- Remote ip:port information- Returns:
- Remote reply
-
sendToPeerWithTimeOut
Synchronize interface with timeout, send a message to the given peer, and get the response- Parameters:
out
- Message to be sentpeerIpPort
- Remote ip:port informationoptions
- Include timeout- Returns:
- Remote reply
-
sendToRandomWithTimeOut
Synchronize interface with timeout, randomly select nodes to send messages- Parameters:
out
- Message to be sentoptions
- Include timeout- Returns:
- Remote reply
-
sendToPeerByRuleWithTimeOut
Synchronize interface with timeout, send message to peer select by client`s rule- Parameters:
out
- Message to be sentrule
- Rule set by clientoptions
- Include timeout- Returns:
- Remote reply
-
asyncSendToPeer
void asyncSendToPeer(Message out, java.lang.String peerIpPort, ResponseCallback callback, Options options)Asynchronous interface, send message to peer- Parameters:
out
- Message to be sentpeerIpPort
- Remote ip:port informationcallback
- Response callbackoptions
- Include timeout
-
asyncSendToRandom
Asynchronous interface, send to an random peer- Parameters:
out
- Message to be sentcallback
- Response callbackoptions
- Include timeout
-
asyncSendToPeerByRule
void asyncSendToPeerByRule(Message out, PeerSelectRule rule, ResponseCallback callback, Options options)Asynchronous interface, send message to peer select by client`s rule- Parameters:
out
- Message to be sentrule
- Rule set by clientcallback
- Response callbackoptions
- Include timeout
-
getConnectionInfo
java.util.List<ConnectionInfo> getConnectionInfo()Get connection information- Returns:
- List of connection information
-
getAvailablePeer
java.util.List<java.lang.String> getAvailablePeer()Get available peer information- Returns:
- List of available peer
-
setThreadPool
void setThreadPool(java.util.concurrent.ExecutorService threadPool)
-