Example #1
0
    public HttpSysListener(HttpSysOptions options, ILoggerFactory loggerFactory)
    {
        if (options == null)
        {
            throw new ArgumentNullException(nameof(options));
        }
        if (loggerFactory == null)
        {
            throw new ArgumentNullException(nameof(loggerFactory));
        }

        if (!HttpApi.Supported)
        {
            throw new PlatformNotSupportedException();
        }

        Debug.Assert(HttpApi.ApiVersion == HttpApiTypes.HTTP_API_VERSION.Version20, "Invalid Http api version");

        Options = options;

        Logger = loggerFactory.CreateLogger <HttpSysListener>();

        _state        = State.Stopped;
        _internalLock = new object();

        // V2 initialization sequence:
        // 1. Create server session
        // 2. Create url group
        // 3. Create request queue
        // 4. Add urls to url group - Done in Start()
        // 5. Attach request queue to url group - Done in Start()

        try
        {
            _serverSession = new ServerSession();

            _requestQueue = new RequestQueue(options.RequestQueueName, options.RequestQueueMode, Logger);

            _urlGroup = new UrlGroup(_serverSession, _requestQueue, Logger);

            _disconnectListener = new DisconnectListener(_requestQueue, Logger);
        }
        catch (Exception exception)
        {
            // If Url group or request queue creation failed, close server session before throwing.
            _requestQueue?.Dispose();
            _urlGroup?.Dispose();
            _serverSession?.Dispose();
            Log.HttpSysListenerCtorError(Logger, exception);
            throw;
        }
    }
Example #2
0
 public void SetDisconnectEventListener(DisconnectListener callback)
 {
     disconnectCallback = callback;
 }
Example #3
0
 public ConnectionCancellation(DisconnectListener parent)
 {
     _parent = parent;
 }
Example #4
0
 public void RemoveDisconnectListener(DisconnectListener listener)
 {
     disconnectListeners.Remove(listener);
 }
Example #5
0
 public void AddDisconnectListener(DisconnectListener disconnectHandler)
 {
     disconnectListeners.Add(disconnectHandler);
 }
Example #6
0
 public void SetDisconnectEventListener(DisconnectListener callback)
 {
     rtClient.SetDisconnectEventListener(callback);
 }
 public void SetDisconnectEventListener(DisconnectListener callback)
 {
     throw new NoSocketIOException();
 }