linvi / tweetinvi

Tweetinvi, an intuitive Twitter C# library for the REST and Stream API. It supports .NET, .NETCore, UAP (Xamarin)...
MIT License
1.01k stars 219 forks source link

Dynamically add tracks/followers while streaming #1108

Open ertan2002 opened 3 years ago

ertan2002 commented 3 years ago

I saw that an issue here . To add a new track or a follow, we have to stop stream and add them and start again.

I got the logic but I am looking for a possible solution.

If I have many dynamic requests and if I stop and restart the stream, I will may miss some tweets (which I do not definitely). To prevent missing some tweets that matched with some filters, what should I do?

My ideas:

1- create another filtered steam and add all filter options there and after a while, dispose the first stream object 2- create a complete TwitterClient object and recreate everything and dispose the first one after a while 3- for each request, create one TwitterClient or a stream (new Task-Thread) and do not dispose (it may be not a good idea) 4- After stop-start the stream, make a search if you miss some tweets from people who you follow.

4th seems fine for me but I am looking for a way which is more efficient. (I don't want to consume system resources a lot)

gem81 commented 3 years ago

use stream v2 In theory. The rules and the flow are separated. If you add a new rule, the thread should immediately start receiving tweets according to two rules.

Just add new rules, and delete old rules. the stream will immediately generate tweets according to the new rules