internal WebSocketClientProxy( string id, WebSocketUnderlyingConnection connection, WebSocketController.FactoryDelegate controllerFactory) : base(connection, controllerFactory) { this.Id = id ?? throw new ArgumentNullException(nameof(id)); }
/// <summary> /// Creates a new websocket client. /// </summary> /// <param name="connection">The connection to be made to the websocket server.</param> /// <param name="controllerFactory"> /// A factory method that creates a controller which implements the client's behavior. /// If this is null, a default no-op controller will be used. /// </param> /// <param name="autoConnect"> /// Connects to the server immediately if true, otherwise the <see cref="Connect" /> method /// must be called to connect this client to the server. /// </param> public WebSocketClient( WebSocketClientConnection connection, WebSocketController.FactoryDelegate controllerFactory = null, bool autoConnect = true) : base(connection, controllerFactory ?? DefaultControllerFactory) { this._socket = connection; this._socket.OnOpen = this.OnOpenInternal; this._socket.OnClose = this.OnCloseInternal; this._socket.OnError = this.OnErrorInternal; this._socket.OnMessage = this.OnMessageInternal; if (autoConnect) { this.Connect().GetAwaiter().GetResult(); } }