kansifang / moquette-mqtt

Automatically exported from code.google.com/p/moquette-mqtt
Apache License 2.0
0 stars 0 forks source link

The pattern based subscription is not working correctly. #13

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I took the code base and it seems that the subscription done using # or + is 
not working. This is due to the issue in how the topic to handler works at 
client side.

In the Client class code 

private Map<String, IPublishCallback> m_subscribersList = new HashMap<String, 
IPublishCallback>();

// in publishCallback
IPublishCallback callback = m_subscribersList.get(topic);
will not return any callBack handlers because the message sent from the broker 
has the complete topic name. 

The fix is quite straight forward 
In SimpleMessangingSubject 

under publish2Subscribers() method

if (qos == QOSType.MOST_ONE) {
                //QoS 0
--                notify(new NotifyEvent(sub.getClientId(), topic, qos, 
message, false));
++                notify(new NotifyEvent(sub.getClientId(), sub.getTopic(), 
qos, message, false));
            }

Original issue reported on code.google.com by moajiz on 20 Aug 2013 at 7:54

GoogleCodeExporter commented 9 years ago

Original comment by selva.an...@gmail.com on 27 Aug 2013 at 4:38