/// <summary> /// Initializes a new instance of the <see cref="VncHandler{T}"/> class. /// </summary> /// <param name="socket"> /// The socket to which the notifications should be send. /// </param> /// <param name="vncContext"> /// The <see cref="VncContext"/> which defines the VNC data to transmit to the client. /// </param> public VncHandler(WebSocket socket, VncContext vncContext) { if (vncContext == null) { throw new ArgumentNullException(nameof(vncContext)); } if (vncContext.FramebufferSource == null || vncContext.Password == null) { throw new ArgumentOutOfRangeException(nameof(vncContext)); } if (socket == null) { throw new ArgumentNullException(nameof(socket)); } this.VncContext = vncContext; this.Socket = socket; this.Vnc = new T(); this.Vnc.PasswordChallenge = vncContext.PasswordChallenge ?? new VncPasswordChallenge(); this.Vnc.Logger = vncContext.Logger; if (vncContext.CreateFramebufferCache != null) { this.Vnc.CreateFramebufferCache = vncContext.CreateFramebufferCache; } this.VncContext.SessionConfiguration?.Invoke(this.Vnc); this.Vnc.Connected += this.OnConnected; this.Vnc.ConnectionFailed += this.OnConnectionFailed; this.Vnc.Closed += this.OnClosed; this.Vnc.PasswordProvided += this.OnPasswordProvided; this.Vnc.SetFramebufferSource(vncContext.FramebufferSource); if (vncContext.RemoteController != null) { this.Vnc.PointerChanged += vncContext.RemoteController.HandleTouchEvent; } if (vncContext.RemoteKeyboard != null) { this.Vnc.KeyChanged += vncContext.RemoteKeyboard.HandleKeyEvent; } }
/// <summary> /// Initializes a new instance of the <see cref="VncVideoHandler"/> class. /// </summary> /// <param name="stream"> /// The <see cref="Stream"/> to which to write the video recording. /// </param> /// <param name="vncContext"> /// The <see cref="VncContext"/> which defines the VNC data to transmit to the client. /// </param> public VncVideoHandler(Stream stream, VncContext vncContext) { if (vncContext == null) { throw new ArgumentNullException(nameof(vncContext)); } if (vncContext.FramebufferSource == null) { throw new ArgumentOutOfRangeException(nameof(vncContext)); } if (stream == null) { throw new ArgumentNullException(nameof(stream)); } this.FramebufferSource = vncContext.FramebufferSource; this.Stream = stream; }