/// <summary> /// Initializes a new instance of the <see cref="GNTPWebSocketReader"/> class. /// </summary> /// <param name="socket">The <see cref="AsyncSocket"/></param> /// <param name="passwordManager">The <see cref="PasswordManager"/> containing a list of allowed passwords</param> /// <param name="passwordRequired">Indicates if a password is required</param> /// <param name="allowNetworkNotifications">Indicates if network requests are allowed</param> /// <param name="allowBrowserConnections">Indicates if browser requests are allowed</param> /// <param name="allowSubscriptions">Indicates if SUBSCRIPTION requests are allowed</param> /// <param name="requestInfo">The <see cref="RequestInfo"/> associated with this request</param> public GNTPWebSocketReader(AsyncSocket socket, PasswordManager passwordManager, bool passwordRequired, bool allowNetworkNotifications, bool allowBrowserConnections, bool allowSubscriptions, RequestInfo requestInfo) : base(socket, passwordManager, passwordRequired, allowNetworkNotifications, allowBrowserConnections, allowSubscriptions, requestInfo) { this.allowed = allowBrowserConnections; parser = new GNTPParser2(passwordManager, passwordRequired, allowNetworkNotifications, allowBrowserConnections, allowSubscriptions, requestInfo); parser.MessageParsed += new GNTPParser2.GNTPParserMessageParsedEventHandler(parser_MessageParsed); parser.Error += new GNTPParser2.GNTPParserErrorEventHandler(parser_Error); }
/// <summary> /// Handles the <see cref="NotifyReceived"/> event /// </summary> /// <param name="notification">The <see cref="Notification"/> that was received</param> /// <param name="callbackInfo">The <see cref="CallbackInfo"/> for the notification</param> /// <param name="requestInfo">The <see cref="RequestInfo"/> associated with the request</param> /// <returns><see cref="Response"/></returns> protected virtual Response OnNotifyReceived(Notification notification, CallbackInfo callbackInfo, RequestInfo requestInfo) { LogInfo("NOTIFICATION RECEIVED: {0}", notification.Name); Response response = new Response(ErrorCode.INTERNAL_SERVER_ERROR, ErrorDescription.INTERNAL_SERVER_ERROR); if (this.NotifyReceived != null) { response = this.NotifyReceived(notification, callbackInfo, requestInfo); } return(response); }
/// <summary> /// Initializes a new instance of the <see cref="GNTPSocketReader"/> class. /// </summary> /// <param name="socket">The <see cref="AsyncSocket"/></param> /// <param name="passwordManager">The <see cref="PasswordManager"/> containing a list of allowed passwords</param> /// <param name="passwordRequired">Indicates if a password is required</param> /// <param name="allowNetworkNotifications">Indicates if network requests are allowed</param> /// <param name="allowBrowserConnections">Indicates if browser requests are allowed</param> /// <param name="allowSubscriptions">Indicates if SUBSCRIPTION requests are allowed</param> /// <param name="requestInfo">The <see cref="RequestInfo"/> associated with this request</param> public GNTPSocketReader(AsyncSocket socket, PasswordManager passwordManager, bool passwordRequired, bool allowNetworkNotifications, bool allowBrowserConnections, bool allowSubscriptions, RequestInfo requestInfo) { this.parser = new GNTPParser(passwordManager, passwordRequired, allowNetworkNotifications, allowBrowserConnections, allowSubscriptions, requestInfo); parser.Error += new GNTPParser.GNTPParserErrorEventHandler(parser_Error); parser.MessageParsed += new GNTPParser.GNTPParserMessageParsedEventHandler(parser_MessageParsed); this.socket = socket; this.socket.Tag = parser; }
/// <summary> /// Handles the <see cref="RegisterReceived"/> event /// </summary> /// <param name="application">The <see cref="Application"/> that is registering</param> /// <param name="notificationTypes">A list of <see cref="NotificationType"/>s being registered</param> /// <param name="requestInfo">The <see cref="RequestInfo"/> associated with the request</param> /// <returns><see cref="Response"/></returns> protected virtual Response OnRegisterReceived(Application application, List <NotificationType> notificationTypes, RequestInfo requestInfo) { LogInfo("REGISTER RECEIVED: {0}", application.Name); Response response = new Response(ErrorCode.INTERNAL_SERVER_ERROR, ErrorDescription.INTERNAL_SERVER_ERROR); if (this.RegisterReceived != null) { response = this.RegisterReceived(application, notificationTypes, requestInfo); } return(response); }
/// <summary> /// Initializes a new instance of the <see cref="GNTPParser"/> class. /// </summary> /// <param name="passwordManager">The <see cref="PasswordManager"/> containing a list of allowed passwords</param> /// <param name="passwordRequired">Indicates if a password is required</param> /// <param name="allowNetworkNotifications">Indicates if network requests are allowed</param> /// <param name="allowBrowserConnections">Indicates if browser requests are allowed</param> /// <param name="allowSubscriptions">Indicates if SUBSCRIPTION requests are allowed</param> /// <param name="requestInfo">The <see cref="RequestInfo"/> associated with this request</param> public GNTPParser(PasswordManager passwordManager, bool passwordRequired, bool allowNetworkNotifications, bool allowBrowserConnections, bool allowSubscriptions, RequestInfo requestInfo) { this.passwordManager = passwordManager; this.passwordRequired = passwordRequired; this.allowNetworkNotifications = allowNetworkNotifications; this.allowBrowserConnections = allowBrowserConnections; this.allowSubscriptions = allowSubscriptions; this.requestInfo = requestInfo; this.alreadyReceived = new StringBuilder(); this.headers = new HeaderCollection(); this.notificationsToBeRegistered = new List <HeaderCollection>(); this.pointers = new List <Pointer>(); this.callbackInfo = new CallbackInfo(); }