void ProcessResponce(String responceString) { Console.WriteLine("Command: " + responceString); dynamic responce = JsonConvert.DeserializeObject(responceString); if (responce.status == "error") { Console.WriteLine($"Error: {responce.description} code: {responce.code}"); if (onError != null) { ClientErrorEventArgs args = new ClientErrorEventArgs(); args.code = responce.code; args.description = responce.description; onError(this, args); } } if (responce.status == "ok") { Console.WriteLine($"Status: {responce.status} Command: {responce.command}"); } if (responce.new_data != null) { EventHandler <ClientVideoEventArgs> handler = videoStateChanged; if (handler != null) { ClientVideoEventArgs args = new ClientVideoEventArgs(); args.file = responce.new_data.file; args.position = TimeSpan.FromSeconds((double)responce.new_data.position); args.state = responce.new_data.state; handler(this, args); } } }
// On error in server private void clientOnError(object sender, ClientErrorEventArgs e) { client.Disconnect(); MessageBox.Show($"{e.description} ({e.code.ToString()})", "Error from server", MessageBoxButton.OK, MessageBoxImage.Error); }