stevenlovegrove / MqttDotNet

.net Implementation of the client half of the MQTT messaging protocol. MQTT is a lightweight, open specification publish and subscribe protocol cheifly developed by IBM. Details of MQTT can be found at http://mqtt.org.
MIT License
153 stars 91 forks source link

Added support for username and password + Updated to VS 2012 #1

Closed kfuglsang closed 11 years ago

kfuglsang commented 11 years ago

I added support for authentication via username/password as specified in the MQTT protocol. I had to update it to Visual Studio 2012 to modify it.

Tested with RabbitMQ 3.0.3's MQTT adapter.

stevenlovegrove commented 11 years ago

This is great, thanks for offering these patches. How do they compare to: https://github.com/mlinnen/MqttDotNet/commit/e832778b793168f341e70469fdc81bb24283bd18

I've been meaning to merge with that commit which supplies the same features. Can you see any advantages of yours over theirs or vice versa?

kfuglsang commented 11 years ago

Thanks for the reply. I was not aware of an existing patch with that functionality. They are indeed very similar.

One difference that comes to mind is that my implementation extends the ConnectionResponse type with support for the "Bad username/password" or "Not authorized" responses from the server. Previously, the response would be parsed as Accepted and the client would then throw an exception on the first message publish.

Other than that, I think it is a matter of preference. I added the username/password to the constructor of the Mqtt class whereas mlinnen added it to the Connect method.

stevenlovegrove commented 11 years ago

I finally got a chance to look over these changes and test them (at least superficially). They seem great, thanks a lot.