private void RemoteDesktopRequestHandler(RemoteDesktopRequest request) { RemoteDesktopResponse response = new RemoteDesktopResponse(request); try { var image = Helpers.RemoteDesktop.CaptureScreenToMemoryStream(request.Quality); var encryptionkey = clientPublicEncryptionkeys[request.SenderClient]; var encript = UtilityFunction.EncryptStream(image, encryptionkey.FirstX, encryptionkey.U, encryptionkey.SelectChoas); response.FrameBytes = encript; } catch (Exception e) { response.HasError = true; response.Exception = e; } SendMessage(response); }
protected virtual void OnMessageReceived(MessageBase msg) { Type type = msg.GetType(); if (msg is ResponseMessageBase) { if (type == typeof(GenericResponse)) { var senderClient = msg.SenderClient; msg = (msg as GenericResponse).ExtractInnerMessage(); msg.SenderClient = senderClient; } if (type == typeof(RemoteDesktopResponse)) { var encryptionkey = clientPublicEncryptionkeys[msg.SenderClient]; var decryptImage = UtilityFunction.EncryptStream((msg as RemoteDesktopResponse).FrameBytes, encryptionkey.FirstX, encryptionkey.U, encryptionkey.SelectChoas); (msg as RemoteDesktopResponse).FrameBytes = decryptImage; } InvokeMessageCallback(msg, (msg as ResponseMessageBase).DeleteCallbackAfterInvoke); if (type == typeof(SessionResponse)) { SessionResponseHandler(msg as SessionResponse); } else if (type == typeof(EndSessionResponse)) { EndSessionResponseHandler(msg as EndSessionResponse); } else if (type == typeof(RemoteDesktopResponse)) { RemoteDesktopResponseHandler(msg as RemoteDesktopResponse); } else if (type == typeof(FileUploadResponse)) { FileUploadResponseHandler(msg as FileUploadResponse); } } else { if (type == typeof(SessionRequest)) { SessionRequestHandler(msg as SessionRequest); } else if (type == typeof(EndSessionRequest)) { EndSessionRequestHandler(msg as EndSessionRequest); } else if (type == typeof(HandShakeRequest)) { HandShakeRequestHandler(msg as HandShakeRequest); } else if (type == typeof(RemoteDesktopRequest)) { RemoteDesktopRequestHandler(msg as RemoteDesktopRequest); } else if (type == typeof(TextMessageRequest)) { TextMessageRequestHandler(msg as TextMessageRequest); } else if (type == typeof(FileUploadRequest)) { FileUploadRequestHandler(msg as FileUploadRequest); } else if (type == typeof(DisconnectRequest)) { DisconnectRequestHandler(msg as DisconnectRequest); } else if (type == typeof(GenericRequest)) { OnGenericRequestReceived(msg as GenericRequest); } } }