public async Task <bool> Freeze(WinId winId) { ThrowIfClientNotReady(); var request = new CPRequest(ObjectName, "Freeze", winId); var response = await client.SendAsync(request) as CPResponse; response.ThrowIfError(); return(response.Success); }
public async Task <bool> SetAutoDetectTiming(WinId winId, bool enable) { ThrowIfClientNotReady(); var request = new CPRequest(ObjectName, "SetAutoDetectTiming", winId, enable ? 1 : 0); var response = await client.SendAsync(request) as CPResponse; response.ThrowIfError(); return(response.Success); }
public async Task <string> GrabImage(WinId winId) { ThrowIfClientNotReady(); var request = new CPRequest(ObjectName, "GrabImage", winId); var response = await client.SendAsync(request) as CPResponse; response.ThrowIfError(); return(response.ValueList.Replace("\"", "")); }
public async Task <string> GetInput(WinId winId) { ThrowIfClientNotReady(); var request = new CPRequest(ObjectName, "GetInput", winId); var response = await client.SendAsync(request) as CPResponse; response.ThrowIfError(); return(response.ValueList); }
public async Task <WinId> NewWindow() { ThrowIfClientNotReady(); var request = new CPRequest(ObjectName, "NewWindow"); var response = await client.SendAsync(request) as CPResponse; response.ThrowIfError(); return(new WinId(response.ValueList)); }
public async Task <TWindowStateList> QueryAllWindows() { ThrowIfClientNotReady(); var request = new CPRequest(ObjectName, "QueryAllWindows"); var response = await client.SendAsync(request) as CPResponse; response.ThrowIfError(); return(new TWindowStateList(response.ValueList)); }
public async Task <SubSystemKind> GetKind() { ThrowIfClientNotReady(); var request = new CPRequest(ObjectName, "GetKind"); var response = await client.SendAsync(request) as CPResponse; response.ThrowIfError(); return((SubSystemKind)Enum.Parse(typeof(SubSystemKind), response.ValueList)); }
public async Task <bool> SetChannel(WinId winId, int chNumber) { ThrowIfClientNotReady(); var request = new CPRequest(ObjectName, "SetChannel", winId, chNumber); var response = await client.SendAsync(request) as CPResponse; response.ThrowIfError(); return(response.Success); }
public async Task <TWindowState> SetState(TWindowState state) { ThrowIfClientNotReady(); var request = new CPRequest(ObjectName, "SetState", state); var response = await client.SendAsync(request) as CPResponse; response.ThrowIfError(); return(new TWindowState(response.ValueList)); }
public async Task <bool> Quit() { ThrowIfClientNotReady(); var request = new CPRequest(ObjectName, "Quit"); var response = await client.SendAsync(request) as CPResponse; response.ThrowIfError(); return(response.Success); }
public async Task <bool> SelectInput(WinId winId, string inputName) { ThrowIfClientNotReady(); var request = new CPRequest(ObjectName, "SelectInput", winId, inputName); var response = await client.SendAsync(request) as CPResponse; response.ThrowIfError(); return(response.Success); }
public async Task <CPScreenConfig> GetScreenConfig() { ThrowIfClientNotReady(); var request = new CPRequest(ObjectName, "GetScreenConfig"); var response = await client.SendAsync(request) as CPResponse; response.ThrowIfError(); return(new CPScreenConfig(response.ValueList)); }
public async Task <int> GetChannel(WinId winId) { ThrowIfClientNotReady(); var request = new CPRequest(ObjectName, "GetChannel", winId); var response = await client.SendAsync(request) as CPResponse; response.ThrowIfError(); int chNumber = int.Parse(response.ValueList); return(chNumber); }
public async Task <CPPlatformInfo> GetServerInfo() { ThrowIfClientNotReady(); var request = new CPRequest(ObjectName, "GetServerInfo"); var response = await client.SendAsync(request) as CPResponse; response.ThrowIfError(); var data = "{ " + response.ValueList + " }"; return(new CPPlatformInfo(data)); }
public async Task <CPServerInfo> GetServerInfo() { // не работает !! // сервер возвращает такое: // { 196613 514589198 30406492 -1941052928 } // вместо сктрктуры из четырех DWORD ThrowIfClientNotReady(); var request = new CPRequest(ObjectName, "GetServerInfo"); var response = await client.SendAsync(request) as CPResponse; response.ThrowIfError(); return(new CPServerInfo(response.ValueList)); }
public async Task <CPRGBTiming> DetectTiming(WinId winId) { // неработает // { 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 } <- сервер возвращает такую хрень... // вместо 12 аргументов - 15 ThrowIfClientNotReady(); var request = new CPRequest(ObjectName, "DetectTiming", winId); var response = await client.SendAsync(request) as CPResponse; response.ThrowIfError(); var data = response.ValueList; return(new CPRGBTiming(data)); }
public async Task <PrevImage> GetPreview(WinId winId) { // недокументированный метод... // судя повсему используется для получения эскизов форм в ContorlPoint-е //= 00000000 128 96DLE... ThrowIfClientNotReady(); var request = new CPRequest(ObjectName, "GetPreview", winId); var response = await client.SendAsync(request) as CPResponse; response.ThrowIfError(); //=00000000 128 96DLE... return(response.Success ? new PrevImage(response.ValueList): null); }
public async Task <Tuple <int, int> > GetChannelRange() { ThrowIfClientNotReady(); var request = new CPRequest(ObjectName, "GetChannelRange"); var response = await client.SendAsync(request) as CPResponse; response.ThrowIfError(); var valueList = response.ValueList; var parts = valueList.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries); var firstCh = int.Parse(parts[0]); var lastCh = int.Parse(parts[1]); return(new Tuple <int, int>(firstCh, lastCh)); }
private CPResponseBase SendInternal(CPRequest request, CancellationToken ct, int timeout) { logger.Debug(request.ToString()); if (!IsConnected) { throw new Exception("Not connected"); } if (state != ClientState.Connected) { throw new Exception("Invalid state: " + state); } CPResponseBase response = null; InvokeCommand command = null; try { command = new InvokeCommand(request, (cSeq++)); StartCommand(command); bool cancel = false; ct.Register(() => { cancel = true; }); Func <bool> cancelled = () => (state != ClientState.Connected || cancel); response = command.WaitResult(timeout, cancelled) as CPResponseBase; } finally { if (command != null) { command.Dispose(); command = null; } } return(response); }
public async Task <bool> Authenticate(string user, string password, int timeout = 5000) { if (isAuthenticated) { return(false); } Credential = new NetworkCredential(user, password); var authRequest = new CPRequest($"{Credential.UserName}\r\n{Credential.Password}\r\n"); var resp = await SendAsync(authRequest, timeout); resp.ThrowIfError(); isAuthenticated = resp?.Success ?? false; return(isAuthenticated); }
public CPResponseBase Send(CPRequest request, int timeout = -1) { return(SendInternal(request, CancellationToken.None, timeout)); }
public Task <CPResponseBase> SendAsync(CPRequest request, int timeout = 10000) { return(SendAsync(request, CancellationToken.None, timeout)); }
public Task <CPResponseBase> SendAsync(CPRequest request, CancellationToken ct, int timeout = 10000) { return(Task.Run(() => SendInternal(request, ct, timeout))); }