/// <summary> /// Initializes a new instance of the <see cref="SubscriptionConnector"/> class /// and allows the communication port to be set. /// </summary> /// <param name="subscriber">The <see cref="Subscriber"/> information/</param> /// <param name="password">The password used to authenticate requests</param> /// <param name="hostname">The hostname of the Growl instance to subscribe to.</param> /// <param name="port">The port of the Growl instance to subscribe to.</param> public SubscriptionConnector(Subscriber subscriber, string password, string hostname, int port) : base(password, hostname, port) { this.subscriber = subscriber; this.timer = new RenewalTimer(); this.timer.AutoReset = false; this.timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed); }
/// <summary> /// Handles the <see cref="SubscribeReceived"/> event /// </summary> /// <param name="subscriber">The <see cref="Subscriber"/> information</param> /// <param name="requestInfo">The <see cref="RequestInfo"/> associated with the request</param> /// <returns><see cref="Response"/></returns> protected virtual Response OnSubscribeReceived(Subscriber subscriber, RequestInfo requestInfo) { LogInfo("SUBSCRIBE RECEIVED: {0}", subscriber.Name); Response response = new Response(ErrorCode.INTERNAL_SERVER_ERROR, ErrorDescription.INTERNAL_SERVER_ERROR); if (this.SubscribeReceived != null) { response = this.SubscribeReceived(subscriber, requestInfo); } return response; }
/// <summary> /// Initializes a new instance of the <see cref="SubscriptionConnector"/> class. /// </summary> /// <param name="subscriber">The <see cref="Subscriber"/> information/</param> /// <param name="password">The password used to authenticate requests</param> /// <param name="hostname">The hostname of the Growl instance to subscribe to.</param> public SubscriptionConnector(Subscriber subscriber, string password, string hostname) : this(subscriber, password, hostname, ConnectorBase.TCP_PORT) { }
/// <summary> /// Creates a new <see cref="Subscriber"/> from a list of headers /// </summary> /// <param name="headers">The <see cref="HeaderCollection"/> used to populate the object</param> /// <returns><see cref="Subscriber"/></returns> public static Subscriber FromHeaders(HeaderCollection headers) { string id = headers.GetHeaderStringValue(Header.SUBSCRIBER_ID, true); string name = headers.GetHeaderStringValue(Header.SUBSCRIBER_NAME, true); int port = headers.GetHeaderIntValue(Header.SUBSCRIBER_PORT, false); if (port == 0) port = GrowlConnector.TCP_PORT; Subscriber subscriber = new Subscriber(id, name, port); SetInhertiedAttributesFromHeaders(subscriber, headers); return subscriber; }