/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// </summary> public void Dispose() { EndStream(); friendsCallback = null; streamStoppedCallback = null; statusCreatedCallback = null; statusDeletedCallback = null; directMessageCreatedCallback = null; directMessageDeletedCallback = null; eventCallback = null; rawJsonCallback = null; }
/// <summary> /// Starts UserStream. /// </summary> /// <param name="friendsCallback">A callback called when UserStream is intialized. This can be null.</param> /// <param name="errorCallback">A callback called when UserStream is stopped. This can be null.</param> /// <param name="statusCreatedCallback">A callback when receive a new status. This can be null.</param> /// <param name="statusDeletedCallback">A callback when a status is deleted. This can be null.</param> /// <param name="dmCreatedCallback">A callback when receive a new direct message. This can be null.</param> /// <param name="dmDeletedCallback">A callback when a direct message is deleted. This can be null.</param> /// <param name="eventCallback">A callback when a new event is raised. This can be null.</param> public void StartStreaming(InitUserStreamCallback friendsCallback, StreamStoppedCallback errorCallback, StatusCreatedCallback statusCreatedCallback, StatusDeletedCallback statusDeletedCallback, DirectMessageCreatedCallback dmCreatedCallback, DirectMessageDeletedCallback dmDeletedCallback, EventCallback eventCallback) { var option = new StreamOptions() { Count = 0 }; stream = new TwitterStream(token, UserAgent, option); stream.StartUserStream(friendsCallback, errorCallback, statusCreatedCallback, statusDeletedCallback, dmCreatedCallback, dmDeletedCallback, eventCallback, null); }
/// <summary> /// Starts the user stream. /// </summary> public IAsyncResult StartUserStream( InitUserStreamCallback friendsCallback, StreamStoppedCallback streamStoppedCallback, StatusCreatedCallback statusCreatedCallback, StatusDeletedCallback statusDeletedCallback, DirectMessageCreatedCallback directMessageCreatedCallback, DirectMessageDeletedCallback directMessageDeletedCallback, EventCallback eventCallback, RawJsonCallback rawJsonCallback = null ) { if (request != null) { throw new InvalidOperationException("Stream is already open"); } WebRequestBuilder builder = new WebRequestBuilder(new Uri("https://userstream.twitter.com/1.1/user.json"), HTTPVerb.GET, Tokens, userAgent); #if !SILVERLIGHT builder.Proxy = Proxy; #endif PrepareStreamOptions(builder); if (StreamOptions != null && StreamOptions is UserStreamOptions) { if ((StreamOptions as UserStreamOptions).AllReplies) { builder.Parameters.Add("replies", "all"); } } request = builder.PrepareRequest(); this.friendsCallback = friendsCallback; this.streamStoppedCallback = streamStoppedCallback; this.statusCreatedCallback = statusCreatedCallback; this.statusDeletedCallback = statusDeletedCallback; this.directMessageCreatedCallback = directMessageCreatedCallback; this.directMessageDeletedCallback = directMessageDeletedCallback; this.eventCallback = eventCallback; this.rawJsonCallback = rawJsonCallback; stopReceived = false; #if SILVERLIGHT request.AllowReadStreamBuffering = false; #else request.Timeout = 10000; #endif return(request.BeginGetResponse(StreamCallback, request)); }
/// <summary> /// Starts the user stream. /// </summary> public async void StartUserStream( InitUserStreamCallback friendsCallback, StreamStoppedCallback streamStoppedCallback, StatusCreatedCallback statusCreatedCallback, StatusDeletedCallback statusDeletedCallback, DirectMessageCreatedCallback directMessageCreatedCallback, DirectMessageDeletedCallback directMessageDeletedCallback, EventCallback eventCallback, RawJsonCallback rawJsonCallback = null ) { if (request != null) { throw new InvalidOperationException("Stream is already open"); } WebRequestBuilder builder = new WebRequestBuilder(new Uri("https://userstream.twitter.com/2/user.json"), HttpMethod.Get, Tokens, userAgent); PrepareStreamOptions(builder); if (StreamOptions != null && StreamOptions is UserStreamOptions) { if ((StreamOptions as UserStreamOptions).AllReplies) { builder.Parameters.Add("replies", "all"); } } request = await builder.PrepareRequestAsync(); this.friendsCallback = friendsCallback; this.streamStoppedCallback = streamStoppedCallback; this.statusCreatedCallback = statusCreatedCallback; this.statusDeletedCallback = statusDeletedCallback; this.directMessageCreatedCallback = directMessageCreatedCallback; this.directMessageDeletedCallback = directMessageDeletedCallback; this.eventCallback = eventCallback; this.rawJsonCallback = rawJsonCallback; stopReceived = false; //request.DefaultRequestHeaders.Timeout = 10000; return(client.GetAsync(request)); ..BeginGetResponse(StreamCallback, request);
/// <summary> /// Starts the user stream. /// </summary> public IAsyncResult StartUserStream( InitUserStreamCallback friendsCallback, StreamStoppedCallback streamErrorCallback, StatusCreatedCallback statusCreatedCallback, StatusDeletedCallback statusDeletedCallback, DirectMessageCreatedCallback directMessageCreatedCallback, DirectMessageDeletedCallback directMessageDeletedCallback, EventCallback eventCallback, RawJsonCallback rawJsonCallback = null ) { WebRequestBuilder builder = new WebRequestBuilder(new Uri("https://userstream.twitter.com/2/user.json"), HTTPVerb.GET, this.Tokens, true, this.UserAgent); PrepareStreamOptions(builder); if (this.StreamOptions != null && this.StreamOptions is UserStreamOptions) { if ((this.StreamOptions as UserStreamOptions).AllReplies) { builder.Parameters.Add("replies", "all"); } } HttpWebRequest request = builder.PrepareRequest(); this.friendsCallback = friendsCallback; this.streamStoppedCallback = streamErrorCallback; this.statusCreatedCallback = statusCreatedCallback; this.statusDeletedCallback = statusDeletedCallback; this.directMessageCreatedCallback = directMessageCreatedCallback; this.directMessageDeletedCallback = directMessageDeletedCallback; this.eventCallback = eventCallback; this.rawJsonCallback = rawJsonCallback; this.stopReceived = false; #if SILVERLIGHT request.AllowReadStreamBuffering = false; #endif return(request.BeginGetResponse(StreamCallback, request)); }
/// <summary> /// Starts the user stream. /// </summary> public IAsyncResult StartUserStream( InitUserStreamCallback friendsCallback, StreamStoppedCallback streamErrorCallback, StatusCreatedCallback statusCreatedCallback, StatusDeletedCallback statusDeletedCallback, DirectMessageCreatedCallback directMessageCreatedCallback, DirectMessageDeletedCallback directMessageDeletedCallback, EventCallback eventCallback, RawJsonCallback rawJsonCallback = null ) { WebRequestBuilder builder = new WebRequestBuilder(new Uri("https://userstream.twitter.com/2/user.json"), HTTPVerb.GET, this.Tokens, true, this.UserAgent); PrepareStreamOptions(builder); if (this.StreamOptions != null && this.StreamOptions is UserStreamOptions) { if ((this.StreamOptions as UserStreamOptions).AllReplies) builder.Parameters.Add("replies", "all"); } HttpWebRequest request = builder.PrepareRequest(); this.friendsCallback = friendsCallback; this.streamStoppedCallback = streamErrorCallback; this.statusCreatedCallback = statusCreatedCallback; this.statusDeletedCallback = statusDeletedCallback; this.directMessageCreatedCallback = directMessageCreatedCallback; this.directMessageDeletedCallback = directMessageDeletedCallback; this.eventCallback = eventCallback; this.rawJsonCallback = rawJsonCallback; this.stopReceived = false; #if SILVERLIGHT request.AllowReadStreamBuffering = false; #endif return request.BeginGetResponse(StreamCallback, request); }
/// <summary> /// Starts the user stream. /// </summary> public IAsyncResult StartUserStream( InitUserStreamCallback friendsCallback, StreamStoppedCallback streamStoppedCallback, StatusCreatedCallback statusCreatedCallback, StatusDeletedCallback statusDeletedCallback, DirectMessageCreatedCallback directMessageCreatedCallback, DirectMessageDeletedCallback directMessageDeletedCallback, EventCallback eventCallback, RawJsonCallback rawJsonCallback = null ) { if (request != null) { throw new InvalidOperationException("Stream is already open"); } WebRequestBuilder builder = new WebRequestBuilder(new Uri("https://userstream.twitter.com/2/user.json"), HTTPVerb.GET, Tokens, userAgent); PrepareStreamOptions(builder); if (StreamOptions != null && StreamOptions is UserStreamOptions) { if ((StreamOptions as UserStreamOptions).AllReplies) builder.Parameters.Add("replies", "all"); } request = builder.PrepareRequest(); this.friendsCallback = friendsCallback; this.streamStoppedCallback = streamStoppedCallback; this.statusCreatedCallback = statusCreatedCallback; this.statusDeletedCallback = statusDeletedCallback; this.directMessageCreatedCallback = directMessageCreatedCallback; this.directMessageDeletedCallback = directMessageDeletedCallback; this.eventCallback = eventCallback; this.rawJsonCallback = rawJsonCallback; stopReceived = false; #if SILVERLIGHT request.AllowReadStreamBuffering = false; #else request.Timeout = 10000; #endif return request.BeginGetResponse(StreamCallback, request); }
/// <summary> /// Starts the user stream. /// </summary> public async void StartUserStream( InitUserStreamCallback friendsCallback, StreamStoppedCallback streamStoppedCallback, StatusCreatedCallback statusCreatedCallback, StatusDeletedCallback statusDeletedCallback, DirectMessageCreatedCallback directMessageCreatedCallback, DirectMessageDeletedCallback directMessageDeletedCallback, EventCallback eventCallback, RawJsonCallback rawJsonCallback = null ) { if (request != null) { throw new InvalidOperationException("Stream is already open"); } WebRequestBuilder builder = new WebRequestBuilder(new Uri("https://userstream.twitter.com/2/user.json"), HttpMethod.Get, Tokens, userAgent); PrepareStreamOptions(builder); if (StreamOptions != null && StreamOptions is UserStreamOptions) { if ((StreamOptions as UserStreamOptions).AllReplies) builder.Parameters.Add("replies", "all"); } request = await builder.PrepareRequestAsync(); this.friendsCallback = friendsCallback; this.streamStoppedCallback = streamStoppedCallback; this.statusCreatedCallback = statusCreatedCallback; this.statusDeletedCallback = statusDeletedCallback; this.directMessageCreatedCallback = directMessageCreatedCallback; this.directMessageDeletedCallback = directMessageDeletedCallback; this.eventCallback = eventCallback; this.rawJsonCallback = rawJsonCallback; stopReceived = false; //request.DefaultRequestHeaders.Timeout = 10000; return client.GetAsync(request);..BeginGetResponse(StreamCallback, request); return null; }