Skip to content

Commit dbd8d5c

Browse files
author
Al S-M
committedDec 1, 2015
Get the seconds value of the KeepAlive value for connect packet
1 parent 755e3fc commit dbd8d5c

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed
 

‎message.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func newConnectMsgFromOptions(options *ClientOptions) *packets.ConnectPacket {
9898
}
9999
}
100100

101-
m.KeepaliveTimer = uint16(options.KeepAlive)
101+
m.KeepaliveTimer = uint16(options.KeepAlive.Seconds())
102102

103103
return m
104104
}

‎unit_options_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func Test_NewClientOptions_mix(t *testing.T) {
4747
o.SetClientID("myclientid")
4848
o.SetUsername("myuser")
4949
o.SetPassword("mypassword")
50-
o.SetKeepAlive(88)
50+
o.SetKeepAlive(88 * time.Second)
5151

5252
if o.Servers[0].Scheme != "tcp" {
5353
t.Fatalf("bad scheme")
@@ -69,8 +69,8 @@ func Test_NewClientOptions_mix(t *testing.T) {
6969
t.Fatalf("bad set password")
7070
}
7171

72-
if o.KeepAlive != 88 {
73-
t.Fatalf("bad set timeout")
72+
if o.KeepAlive != 88000000000 {
73+
t.Fatalf("bad set timeout: %d", o.KeepAlive)
7474
}
7575
}
7676

0 commit comments

Comments
 (0)
Please sign in to comment.