Skip to content

Commit

Permalink
Send will message when session is taken over
Browse files Browse the repository at this point in the history
  • Loading branch information
icraggs committed Oct 30, 2023
1 parent 577f955 commit a4dc694
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions interoperability/mqtt/brokers/V311/MQTTBrokers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
*******************************************************************
Copyright (c) 2013, 2018 IBM Corp.
Copyright (c) 2013, 2023 IBM Corp.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
Expand Down Expand Up @@ -295,7 +295,7 @@ def connect(self, sock, packet):
for s in self.clients.keys():
if self.clients[s].id == packet.ClientIdentifier:
logger.info("[MQTT-3.1.4-2] Disconnecting old client %s", packet.ClientIdentifier)
self.disconnect(s, None)
self.disconnect(s, None, terminate=True)
break
me = None
if not packet.CleanSession:
Expand Down
10 changes: 5 additions & 5 deletions interoperability/mqtt/brokers/V5/MQTTBrokers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
*******************************************************************
Copyright (c) 2013, 2020 IBM Corp.
Copyright (c) 2013, 2023 IBM Corp.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
Expand Down Expand Up @@ -319,7 +319,7 @@ def __init__(self, options={}, lock=None, sharedData={}):
self.mscfile.write("msc {\n broker;\n")

def shutdown(self):
self.disconnectAll()
self.disconnectAll(reasonCode="Server shutting down")
self.cleanupThread.stop()

def setBroker3(self, broker3):
Expand Down Expand Up @@ -436,7 +436,7 @@ def connect(self, sock, packet):
for cursock in self.clients.keys():
if self.clients[cursock].id == packet.ClientIdentifier:
logger.info("[MQTT5-3.1.4-3] Disconnecting old client %s", packet.ClientIdentifier)
self.disconnect(cursock, reasonCode="Session taken over")
self.disconnect(cursock, reasonCode="Session taken over", sendWillMessage=True)
break
me = None
clean = False
Expand Down Expand Up @@ -542,9 +542,9 @@ def disconnect(self, sock, packet=None, sendWillMessage=False, reasonCode=None,
except:
pass # doesn't matter if the socket has been closed at the other end already

def disconnectAll(self):
def disconnectAll(self, reasonCode=None):
for sock in list(self.clients.keys())[:]:
self.disconnect(sock, None)
self.disconnect(sock, None, reasonCode=reasonCode)

def subscribe(self, sock, packet):
topics = []
Expand Down

0 comments on commit a4dc694

Please sign in to comment.