mirror of
https://github.com/duanhf2012/origin.git
synced 2026-03-06 22:27:36 +08:00
新增判断连接状态接口
This commit is contained in:
@@ -145,3 +145,8 @@ func GetRpcClient(nodeId int,serviceMethod string) ([]*rpc.Client,error) {
|
|||||||
func GetRpcServer() *rpc.Server{
|
func GetRpcServer() *rpc.Server{
|
||||||
return &cluster.rpcServer
|
return &cluster.rpcServer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (slf *Cluster) IsNodeConnected (nodeId int) bool {
|
||||||
|
pClient := slf.GetRpcClient(nodeId)
|
||||||
|
return pClient!=nil && pClient.IsConnected()
|
||||||
|
}
|
||||||
|
|||||||
@@ -111,3 +111,7 @@ func (tcpConn *TCPConn) ReadMsg() ([]byte, error) {
|
|||||||
func (tcpConn *TCPConn) WriteMsg(args ...[]byte) error {
|
func (tcpConn *TCPConn) WriteMsg(args ...[]byte) error {
|
||||||
return tcpConn.msgParser.Write(tcpConn, args...)
|
return tcpConn.msgParser.Write(tcpConn, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (tcpConn *TCPConn) IsConnected() bool {
|
||||||
|
return tcpConn.closeFlag == false
|
||||||
|
}
|
||||||
@@ -219,3 +219,7 @@ func (slf *Client) Run(){
|
|||||||
|
|
||||||
func (slf *Client) OnClose(){
|
func (slf *Client) OnClose(){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (slf *Client) IsConnected() bool {
|
||||||
|
return slf.conn!=nil && slf.conn.IsConnected()==true
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user