Skip to content

Commit

Permalink
added support for mqtt user and password
Browse files Browse the repository at this point in the history
  • Loading branch information
Sarwar Bhuiyan committed Apr 10, 2014
1 parent 70fec56 commit a6adf55
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
4 changes: 3 additions & 1 deletion include/ts_mqtt.hrl
Expand Up @@ -38,7 +38,9 @@
topic,
qos = 0,
retained = false,
payload
payload,
username,
password
}).

-record(mqtt_dyndata, {
Expand Down
7 changes: 5 additions & 2 deletions src/tsung_controller/ts_config_mqtt.erl
Expand Up @@ -51,6 +51,10 @@ parse_config(Element = #xmlElement{name = mqtt},
Type = ts_config:getAttr(atom, Element#xmlElement.attributes, type),
CleanStart = ts_config:getAttr(atom, Element#xmlElement.attributes,
clean_start, true),
UserName = ts_config:getAttr(string, Element#xmlElement.attributes,
username, ""),

This comment has been minimized.

Copy link
@nniclausse

nniclausse Apr 10, 2014

after reading mqtt_frame.erl, it seems that the default value of username and password should be the atom 'undefined' instead of "", no ?

Password = ts_config:getAttr(string, Element#xmlElement.attributes,
password, ""),
KeepAlive = ts_config:getAttr(float_or_integer, Element#xmlElement.attributes,
keepalive, 10),
WillTopic = ts_config:getAttr(string, Element#xmlElement.attributes,
Expand Down Expand Up @@ -78,7 +82,7 @@ parse_config(Element = #xmlElement{name = mqtt},
keepalive = KeepAlive, will_topic = WillTopic,
will_qos = WillQos, will_msg = WillMsg,
will_retain = WillRetain, topic = Topic, qos = Qos,
retained = RetainValue, payload = Payload},
retained = RetainValue, payload = Payload, username = UserName, password = Password},
Ack = case {Type, Qos} of
{publish, 0} -> no_ack;
{disconnect, _} -> no_ack;
Expand Down Expand Up @@ -112,4 +116,3 @@ parse_config(Element = #xmlElement{}, Conf = #config{}) ->
%% Parsing non #xmlElement elements
parse_config(_, Conf = #config{}) ->
Conf.

6 changes: 4 additions & 2 deletions tsung-1.0.dtd
Expand Up @@ -371,7 +371,7 @@ repeat | if | change_type | foreach | set_option | interaction )*>
path CDATA "/" >

<!ELEMENT amqp (#PCDATA) >
<!ATTLIST amqp
<!ATTLIST amqp
type CDATA #REQUIRED
vhost CDATA "/"
channel CDATA "-1"
Expand All @@ -398,7 +398,9 @@ repeat | if | change_type | foreach | set_option | interaction )*>
topic CDATA ""
qos CDATA "0"
retained CDATA "false"
timeout CDATA "1" >
timeout CDATA "1"
username CDATA ""
password CDATA "">

<!ELEMENT modification (attr*) >
<!ATTLIST modification
Expand Down

0 comments on commit a6adf55

Please sign in to comment.