Skip to content

Commit

Permalink
Add 1.5 second wait time when logging into Cytube
Browse files Browse the repository at this point in the history
to let rank initialize. See also #85.
  • Loading branch information
d-dd committed Oct 6, 2016
1 parent c1fe8f5 commit c8b4fb1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
*.py[cod]
*.db
*.db-shm
*.db-wal
*.swp
*.flv
*.json
Expand Down
17 changes: 8 additions & 9 deletions connections/cytube/cyClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,10 @@ def onOpen(self):
self.lifeline = None
self.heartbeat.start(20.0, now=True)
self.finalHeartbeat = None
self.initialize()
# wait one second before logging in
# to make sure rank is properly initialized
# eventually check for "rank" frame
reactor.callLater(1.5, self.initialize)

def abandon(self):
"""
Expand Down Expand Up @@ -724,14 +727,10 @@ def userJoin(self, user, timeNow):
# add a reference to the deferred to the userdict
self.userdict[user['name']]['deferred'] = d

try:
profileText = user['profile']['text']
profileImgUrl = user['profile']['image']
except:
p = json.loads(user['profile'])
clog.error(p)
profileText = p['text']
profileImgUrl = p['image']
profileText, profileImgUrl = (None, None)
if user.get('profile'):
profileText = user['profile'].get('text')
profileImgUrl = user['profile'].get('image')
d.addCallback(self.updateProfile, profileText, profileImgUrl)

def updateProfile(self, userId, profileText, profileImgUrl):
Expand Down

0 comments on commit c8b4fb1

Please sign in to comment.