Allow Broker DisConnect connections by ClientId (#135)
* Allow Broker DisConnect connections by ClientId * Allow Broker DisConnect connections by ClientId
This commit is contained in:
1 parent
878e7fce3f
commit
ab117be4a8
3 files changed
+16
-2
No files matched your search
@@ -2,6 +2,8 @@ hmq
|
|||||||
log
|
log
|
||||||
log/*
|
log/*
|
||||||
*.test
|
*.test
|
||||||
|
# ide
|
||||||
|
.idea
|
||||||
.vscode/settings.json
|
.vscode/settings.json
|
||||||
.pre-commit-config.yaml
|
.pre-commit-config.yaml
|
||||||
hmq.exe
|
hmq.exe
|
||||||
@@ -255,6 +255,18 @@ func (b *Broker) StartClusterListening() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (b *Broker) DisConnClientByClientId(clientId string) {
|
||||||
|
cli, loaded := b.clients.LoadAndDelete(clientId)
|
||||||
|
if !loaded {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
conn, success := cli.(*client)
|
||||||
|
if !success {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
conn.Close()
|
||||||
|
}
|
||||||
|
|
||||||
func (b *Broker) handleConnection(typ int, conn net.Conn) {
|
func (b *Broker) handleConnection(typ int, conn net.Conn) {
|
||||||
//process connect packet
|
//process connect packet
|
||||||
packet, err := packets.ReadPacket(conn)
|
packet, err := packets.ReadPacket(conn)
|
||||||
|
|||||||
+2
-2
@@ -11,8 +11,8 @@ func InitHTTPMoniter(b *Broker) {
|
|||||||
clientid := c.Param("clientid")
|
clientid := c.Param("clientid")
|
||||||
cli, ok := b.clients.Load(clientid)
|
cli, ok := b.clients.Load(clientid)
|
||||||
if ok {
|
if ok {
|
||||||
conn, succss := cli.(*client)
|
conn, success := cli.(*client)
|
||||||
if succss {
|
if success {
|
||||||
conn.Close()
|
conn.Close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user