Skip to content

Commit

Permalink
Fix heartbeat calculation
Browse files Browse the repository at this point in the history
Need to compare client outgoing/incoming with server incoming/outgoing,
not server outgoing/incoming.
  • Loading branch information
scop committed Aug 10, 2015
1 parent ed510a7 commit 4d79841
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
13 changes: 13 additions & 0 deletions stomp/test/utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,16 @@ def test_parse_headers(self):
]
self.assertEquals(
{'h1': r'foo:\bar ', 'h:2': 'baz\r\nquux'}, parse_headers(lines))

def test_calculate_heartbeats(self):
chb = (3000, 5000)
shb = map(str, reversed(chb))
self.assertEquals((3000, 5000), calculate_heartbeats(shb, chb))
shb = ('6000', '2000')
self.assertEquals((3000, 6000), calculate_heartbeats(shb, chb))
shb = ('0', '0')
self.assertEquals((0, 0), calculate_heartbeats(shb, chb))
shb = ('10000', '0')
self.assertEquals((0, 10000), calculate_heartbeats(shb, chb))
chb = (0, 0)
self.assertEquals((0, 0), calculate_heartbeats(shb, chb))
4 changes: 2 additions & 2 deletions stomp/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ def calculate_heartbeats(shb, chb):
x = 0
y = 0
if cx != 0 and sy != '0':
x = max(cx, int(sx))
x = max(cx, int(sy))
if cy != 0 and sx != '0':
y = max(cy, int(sy))
y = max(cy, int(sx))
return (x, y)


Expand Down

0 comments on commit 4d79841

Please sign in to comment.