mirror of
https://github.com/jwetzell/QControlKit.git
synced 2026-08-20 06:29:06 +00:00
Add WorkspaceConnectionError Event
This commit is contained in:
@@ -93,7 +93,7 @@ namespace QControlKit
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log.Debug($"[client] unhandled reply from cue: Type: {data.Type} value: {message.response}");
|
Log.Warning($"[client] unhandled reply from cue: Type: {data.Type} value: {message.response}");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -107,6 +107,7 @@ namespace QControlKit
|
|||||||
}
|
}
|
||||||
else if (message.IsConnect)
|
else if (message.IsConnect)
|
||||||
{
|
{
|
||||||
|
//Log.Debug($"[client] Connection message received: {message.response}");
|
||||||
if (message.response.ToString() == "ok")
|
if (message.response.ToString() == "ok")
|
||||||
OnWorkspaceConnected();
|
OnWorkspaceConnected();
|
||||||
else
|
else
|
||||||
@@ -114,7 +115,7 @@ namespace QControlKit
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log.Debug($"[client] unhandled reply message: {message.address}");
|
Log.Warning($"[client] unhandled reply message: {message.address}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(message.IsUpdate) {
|
else if(message.IsUpdate) {
|
||||||
@@ -154,17 +155,16 @@ namespace QControlKit
|
|||||||
}
|
}
|
||||||
else if (message.IsDisconnect)
|
else if (message.IsDisconnect)
|
||||||
{
|
{
|
||||||
Log.Debug($"[client] disconnect message received: {message.address}");
|
|
||||||
OnWorkspaceDisconnected();
|
OnWorkspaceDisconnected();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log.Debug($"[client] unhandled update message: {message.address}");
|
Log.Warning($"[client] unhandled update message: {message.address}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log.Debug($"[client] unhandled message: {message.address}");
|
Log.Warning($"[client] unhandled message: {message.address}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<Authors>Joel Wetzell</Authors>
|
<Authors>Joel Wetzell</Authors>
|
||||||
<Version>1.0.0-devel</Version>
|
<Version>1.0.0-devel</Version>
|
||||||
<PackOnBuild>true</PackOnBuild>
|
<PackOnBuild>true</PackOnBuild>
|
||||||
<PackageVersion>0.0.1</PackageVersion>
|
<PackageVersion>0.0.3</PackageVersion>
|
||||||
<PackageId>QControlKit</PackageId>
|
<PackageId>QControlKit</PackageId>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
//General information about a QLab Workspace
|
using Serilog;
|
||||||
using Serilog;
|
|
||||||
using System.Collections.Concurrent;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Zeroconf;
|
using Zeroconf;
|
||||||
|
|
||||||
|
|||||||
+27
-11
@@ -1,4 +1,4 @@
|
|||||||
//TODO: connect methods, cue property fetch methods, everything else
|
//TODO: workspace connection error handlers
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
using System;
|
using System;
|
||||||
@@ -32,6 +32,8 @@ namespace QControlKit
|
|||||||
|
|
||||||
public event QWorkspaceUpdatedHandler WorkspaceUpdated;
|
public event QWorkspaceUpdatedHandler WorkspaceUpdated;
|
||||||
public event QCueListChangedPlaybackPositionHandler CueListChangedPlaybackPosition;
|
public event QCueListChangedPlaybackPositionHandler CueListChangedPlaybackPosition;
|
||||||
|
public event QWorkspaceConnectionErrorHandler WorkspaceConnectionError;
|
||||||
|
|
||||||
private void Init()
|
private void Init()
|
||||||
{
|
{
|
||||||
name = "";
|
name = "";
|
||||||
@@ -52,9 +54,6 @@ namespace QControlKit
|
|||||||
|
|
||||||
public QWorkspace(QWorkspaceInfo workspaceInfo, QServer server)
|
public QWorkspace(QWorkspaceInfo workspaceInfo, QServer server)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (workspaceInfo.version.Length > 0)
|
if (workspaceInfo.version.Length > 0)
|
||||||
version = workspaceInfo.version;
|
version = workspaceInfo.version;
|
||||||
|
|
||||||
@@ -143,19 +142,30 @@ namespace QControlKit
|
|||||||
|
|
||||||
#region Connection/reconnection
|
#region Connection/reconnection
|
||||||
|
|
||||||
public void connectWithPasscode(string passcode)
|
public void connect(string passcode = null)
|
||||||
{
|
{
|
||||||
//TODO
|
Log.Debug($"[workspace] connecting to {this.server.host} with passcode: {passcode}");
|
||||||
|
|
||||||
|
if(hasPasscode && passcode == null)
|
||||||
|
{
|
||||||
|
Log.Error($"[workspace] *** workspace <{name}> requires a passcode but none was supplied.");
|
||||||
|
OnWorkspaceConnectionError(this, new QWorkspaceConnectionErrorArgs { status = "badpass" });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!client.connect())
|
if (!client.connect())
|
||||||
{
|
{
|
||||||
Log.Error($"[workspace] *** Error: couldn't connect to server client is not connected");
|
Log.Error($"[workspace] *** couldn't connect to server client is not connected");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//save password for reuse
|
//save password for reuse
|
||||||
this.passcode = passcode;
|
this.passcode = passcode;
|
||||||
Log.Information("[workspace] connecting...");
|
Log.Information("[workspace] connecting...");
|
||||||
client.sendMessage($"{workspacePrefix}/connect",passcode);
|
if (passcode != null)
|
||||||
|
client.sendMessage($"{workspacePrefix}/connect", passcode);
|
||||||
|
else
|
||||||
|
client.sendMessage($"{workspacePrefix}/connect");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void finishConnection()
|
private void finishConnection()
|
||||||
@@ -173,7 +183,10 @@ namespace QControlKit
|
|||||||
{
|
{
|
||||||
if (connected)
|
if (connected)
|
||||||
return;
|
return;
|
||||||
connectWithPasscode(passcode);
|
if(hasPasscode)
|
||||||
|
connect(passcode);
|
||||||
|
else
|
||||||
|
connect();
|
||||||
|
|
||||||
//todo
|
//todo
|
||||||
}
|
}
|
||||||
@@ -384,12 +397,15 @@ namespace QControlKit
|
|||||||
if (args.status.Equals("badpass"))
|
if (args.status.Equals("badpass"))
|
||||||
{
|
{
|
||||||
//clear passcode if there was one set in the connect() method
|
//clear passcode if there was one set in the connect() method
|
||||||
this.passcode = "";
|
this.passcode = null;
|
||||||
Log.Error($"[workspace] *** Password for workspace {name} was incorrect!");
|
Log.Error($"[workspace] *** Password for workspace {name} was incorrect!");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
Log.Error($"[workspace] *** Unable to connect to workspace: {name} on server: {server.name}");
|
Log.Error($"[workspace] *** Unable to connect to workspace: {name} on server: {server.name}");
|
||||||
|
}
|
||||||
|
|
||||||
|
WorkspaceConnectionError?.Invoke(this, new QWorkspaceConnectionErrorArgs { status = args.status });
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnWorkspaceConnected(object source, QWorkspaceConnectedArgs args)
|
private void OnWorkspaceConnected(object source, QWorkspaceConnectedArgs args)
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using QControlKit;
|
using QControlKit;
|
||||||
using QControlKitXamDemo.ViewModels;
|
using QControlKitXamDemo.ViewModels;
|
||||||
@@ -12,17 +11,39 @@ namespace QControlKitXamDemo
|
|||||||
{
|
{
|
||||||
private QWorkspace connectedWorkspace;
|
private QWorkspace connectedWorkspace;
|
||||||
private Dictionary<string, Grid> cueGridDict = new Dictionary<string, Grid>();
|
private Dictionary<string, Grid> cueGridDict = new Dictionary<string, Grid>();
|
||||||
public CueListPage(QWorkspace workspace)
|
public CueListPage(QWorkspace workspace, string passcode = null)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
connectedWorkspace = workspace;
|
connectedWorkspace = workspace;
|
||||||
connectedWorkspace.WorkspaceUpdated += Workspace_WorkspaceUpdated;
|
connectedWorkspace.WorkspaceUpdated += Workspace_WorkspaceUpdated;
|
||||||
connectedWorkspace.connectWithPasscode("1234");
|
connectedWorkspace.WorkspaceConnectionError += ConnectedWorkspace_WorkspaceConnectionError;
|
||||||
|
connectedWorkspace.connect(passcode);
|
||||||
connectedWorkspace.defaultSendUpdatesOSC = true;
|
connectedWorkspace.defaultSendUpdatesOSC = true;
|
||||||
connectedWorkspace.CueListChangedPlaybackPosition += ConnectedWorkspace_CueListChangedPlaybackPosition;
|
connectedWorkspace.CueListChangedPlaybackPosition += ConnectedWorkspace_CueListChangedPlaybackPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnDisappearing()
|
||||||
|
{
|
||||||
|
base.OnDisappearing();
|
||||||
|
connectedWorkspace.disconnect();
|
||||||
|
connectedWorkspace.WorkspaceUpdated -= Workspace_WorkspaceUpdated;
|
||||||
|
connectedWorkspace.WorkspaceConnectionError -= ConnectedWorkspace_WorkspaceConnectionError;
|
||||||
|
connectedWorkspace.CueListChangedPlaybackPosition -= ConnectedWorkspace_CueListChangedPlaybackPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void ConnectedWorkspace_WorkspaceConnectionError(object source, QWorkspaceConnectionErrorArgs args)
|
||||||
|
{
|
||||||
|
System.Console.WriteLine("WorkspaceConnectionError Called");
|
||||||
|
if (args.status.Equals("badpass"))
|
||||||
|
{
|
||||||
|
string passcode = await DisplayPromptAsync("Passcode was incorrect.", "Try Again", maxLength: 4, keyboard: Keyboard.Numeric);
|
||||||
|
if (passcode != null)
|
||||||
|
{
|
||||||
|
connectedWorkspace.connect(passcode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ConnectedWorkspace_CueListChangedPlaybackPosition(object source, QCueListChangedPlaybackPositionArgs args)
|
void ConnectedWorkspace_CueListChangedPlaybackPosition(object source, QCueListChangedPlaybackPositionArgs args)
|
||||||
{
|
{
|
||||||
Device.BeginInvokeOnMainThread(() =>
|
Device.BeginInvokeOnMainThread(() =>
|
||||||
|
|||||||
@@ -25,9 +25,26 @@ namespace QControlKitXamDemo
|
|||||||
|
|
||||||
async void ServerListView_ItemSelected(object sender, SelectedItemChangedEventArgs e)
|
async void ServerListView_ItemSelected(object sender, SelectedItemChangedEventArgs e)
|
||||||
{
|
{
|
||||||
QWorkspace selectedWorkspace = e.SelectedItem as QWorkspace;
|
if(e.SelectedItem != null)
|
||||||
Console.WriteLine($"[demo] workspace: {selectedWorkspace.nameWithoutPathExtension} has been selected");
|
{
|
||||||
await Navigation.PushAsync(new CueListPage(selectedWorkspace));
|
QWorkspace selectedWorkspace = e.SelectedItem as QWorkspace;
|
||||||
|
Console.WriteLine($"[demo] workspace: {selectedWorkspace.nameWithoutPathExtension} has been selected");
|
||||||
|
if (selectedWorkspace.hasPasscode)
|
||||||
|
{
|
||||||
|
string passcode = await DisplayPromptAsync("Workspace has passcode", "Enter Passcode", maxLength: 4, keyboard: Keyboard.Numeric);
|
||||||
|
if (passcode != null)
|
||||||
|
{
|
||||||
|
|
||||||
|
await Navigation.PushAsync(new CueListPage(selectedWorkspace, passcode));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await Navigation.PushAsync(new CueListPage(selectedWorkspace));
|
||||||
|
|
||||||
|
}
|
||||||
|
serverListView.SelectedItem = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Browser_ServerUpdatedWorkspaces(object source, QServerUpdatedArgs args)
|
private void Browser_ServerUpdatedWorkspaces(object source, QServerUpdatedArgs args)
|
||||||
|
|||||||
Reference in New Issue
Block a user