private Uri GetBaseUrl(IPusherOptions _options) { string baseUrl = (_options.Encrypted ? "https" : "http") + "://" + DEFAULT_REST_API_HOST + (_options.Port == 80 ? "" : ":" + _options.Port); return(new Uri(baseUrl)); }
/// <summary> /// Initializes a new instance of the <see cref="Pusher" /> class. /// </summary> /// <param name="appId">The app id.</param> /// <param name="appKey">The app key.</param> /// <param name="appSecret">The app secret.</param> /// <param name="options">Additional options to be used with the instance e.g. setting the call to the REST API to be made over HTTPS.</param> public Pusher(string appId, string appKey, string appSecret, IPusherOptions options) { ThrowArgumentExceptionIfNullOrEmpty(appId, "appId"); ThrowArgumentExceptionIfNullOrEmpty(appKey, "appKey"); ThrowArgumentExceptionIfNullOrEmpty(appSecret, "appSecret"); if (options == null) { options = new PusherOptions(); } _appId = appId; _appKey = appKey; _appSecret = appSecret; _options = options; }
/// <summary> /// Initializes a new instance of the <see cref="Pusher" /> class. /// </summary> /// <param name="appId">The app id.</param> /// <param name="appKey">The app key.</param> /// <param name="appSecret">The app secret.</param> /// <param name="options">(Optional)Additional options to be used with the instance e.g. setting the call to the REST API to be made over HTTPS.</param> public Pusher(string appId, string appKey, string appSecret, IPusherOptions options = null) { ThrowArgumentExceptionIfNullOrEmpty(appId, "appId"); ThrowArgumentExceptionIfNullOrEmpty(appKey, "appKey"); ThrowArgumentExceptionIfNullOrEmpty(appSecret, "appSecret"); if (options == null) { options = new PusherOptions(); } _appKey = appKey; _appSecret = appSecret; _options = options; _factory = new AuthenticatedRequestFactory(appKey, appId, appSecret); }
/// <summary> /// Validates the size of the data field for a batch event. /// </summary> /// <param name="data">The data field to validate.</param> /// <param name="channelName">The name of a channel associated with event data.</param> /// <param name="eventName">The name of the event.</param> /// <param name="options">The current <see cref="IPusherOptions"/>.</param> /// <exception cref="EventDataSizeExceededException">If the size of <paramref name="data"/> is greater than the expected.</exception> /// <remarks>Note: the size of the data field is only validated if the <c>IPusherOption.BatchEventDataSizeLimit</c> is specified.</remarks> internal static void ValidateBatchEventData(string data, string channelName, string eventName, IPusherOptions options) { if (options != null && options.BatchEventDataSizeLimit.HasValue) { if (data != null && data.Length > options.BatchEventDataSizeLimit.Value) { throw new EventDataSizeExceededException(options.BatchEventDataSizeLimit.Value, data.Length) { ChannelName = channelName, EventName = eventName, }; } } }