From: Joshua Roesslein Date: Sun, 19 May 2013 06:58:26 +0000 (-0700) Subject: Implement StreamListener.on_connect callback. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=5e06813723ad4b51c9390b415a0f12d428cbee9c;p=tweepy.git Implement StreamListener.on_connect callback. --- diff --git a/tweepy/streaming.py b/tweepy/streaming.py index b1bb4b2..f6d37f4 100644 --- a/tweepy/streaming.py +++ b/tweepy/streaming.py @@ -22,6 +22,15 @@ class StreamListener(object): def __init__(self, api=None): self.api = api or API() + def on_connect(self): + """Called once connected to streaming server. + + This will be invoked once a successful response + is received from the server. Allows the listener + to perform some work prior to entering the read loop. + """ + pass + def on_data(self, data): """Called when raw data is received from connection. @@ -114,6 +123,7 @@ class Stream(object): sleep(self.retry_time) else: error_counter = 0 + self.listener.on_connect() self._read_loop(resp) except timeout: if self.listener.on_timeout() == False: