private void ProcessMessages()
{
Task.Factory.StartNew(ReadLines, CancelStream.Token);
readLinesObservable.Subscribe(line =>
{
#region Main Observer work here
#if (DEBUG)
Debug.WriteLine(line);
#endif
#if (TRACE)
if (line == "ENDBOXKITEUSERSTREAMTEST")
{
Stop();
}
#endif
if (string.IsNullOrWhiteSpace(line)) return;
if (line == "<html>") // todo: needs embellishment, especially as Twitter uses HTML embedded in stream for errors
{
Stop();
}
var obj = JsonConvert.DeserializeObject<JObject>(line);
if (obj["in_reply_to_user_id"] != null)
{
_foundtweets.OnNext(MapFromStreamTo<Tweet>(obj.ToString()));
}
#endregion
});
}