mirror of
https://github.com/jwetzell/qController.git
synced 2026-08-17 05:13:40 +00:00
BIG TCP Overhaul and passcode start
- Switch to Serilog for console logging - TCPSender is now persistent (let's hope) so can be used with passcode protected workspaces - UDP connection works with passcodes just can't timeout - Passcode prompt is automatic for workspaces that are password protected
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
//Class used to facilitate communication with a QInstance
|
||||
//Listens for incoming messages via qReceiver (UDP) and tcpSender (TCP)
|
||||
//WEIRD MESSAGE PARSING RULES NEED FIXED
|
||||
//TODO: WEIRD MESSAGE PARSING RULES NEED FIXED
|
||||
using System;
|
||||
using SharpOSC;
|
||||
using Serilog;
|
||||
|
||||
namespace qController
|
||||
{
|
||||
@@ -22,7 +23,8 @@ namespace qController
|
||||
qParser = new QParser();
|
||||
qReceiver = new QReceiver(Port + 1);
|
||||
tcpSender = new TCPSender(Address, Port);
|
||||
//udpSender = new UDPSender(Address, Port);
|
||||
tcpSender.Connect();
|
||||
udpSender = new UDPSender(Address, Port);
|
||||
|
||||
tcpSender.MessageReceived += OnMessageReceived;
|
||||
qReceiver.UpdateMessageReceived += OnMessageReceived;
|
||||
@@ -32,8 +34,10 @@ namespace qController
|
||||
//one method for messages received whether from TCP or UDP (SAME MSG FORMAT)
|
||||
private void OnMessageReceived(object source, MessageEventArgs args)
|
||||
{
|
||||
Console.WriteLine("QCLIENT - Message Received: " + args.Message.Address);
|
||||
//try to find a better filtering process
|
||||
Log.Debug("QCLIENT - Message Received: " + args.Message.Address);
|
||||
|
||||
|
||||
//TODO: find a better filtering process
|
||||
if (!args.Message.Address.Contains("update"))
|
||||
qParser.ParseMessage(args.Message);
|
||||
else if (args.Message.Address.Contains("playbackPosition") || args.Message.Address.Contains("cueList") || args.Message.Address.Contains("dashboard"))
|
||||
@@ -55,61 +59,54 @@ namespace qController
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("QCLIENT - Send Exception: " + ex.Message);
|
||||
Log.Debug("QCLIENT - Send Exception: " + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void sendArgs(string address, object args)
|
||||
public void sendUDP(string address)
|
||||
{
|
||||
Log.Debug($"QCLIENT - UDP Sent with address: {address}");
|
||||
udpSender = new UDPSender(Address,Port);
|
||||
udpSender.Send(new OscMessage(address));
|
||||
udpSender.Close();
|
||||
}
|
||||
public void sendUDP(string address, params object[] args)
|
||||
{
|
||||
Log.Debug($"QCLIENT - UDP Sent with address: {address}");
|
||||
udpSender = new UDPSender(Address, Port);
|
||||
udpSender.Send(new OscMessage(address, args));
|
||||
udpSender.Close();
|
||||
}
|
||||
public void sendTCP(string address)
|
||||
{
|
||||
Log.Debug($"QCLIENT - TCP Sent with address: {address}");
|
||||
try
|
||||
{
|
||||
tcpSender.Send(new OscMessage(address));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Debug("QCLIENT - Send and Receive Exception: " + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void sendTCP(string address, params object[] args)
|
||||
{
|
||||
Log.Debug($"QCLIENT - TCP Sent with address: {address}");
|
||||
try
|
||||
{
|
||||
tcpSender.Send(new OscMessage(address, args));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("QCLIENT - Send w/Args Exception: " + ex.Message);
|
||||
}
|
||||
}
|
||||
public void sendStringUDP(string address)
|
||||
{
|
||||
udpSender = new UDPSender(Address,Port);
|
||||
udpSender.Send(new OscMessage(address));
|
||||
udpSender.Close();
|
||||
}
|
||||
public void sendArgsUDP(string address, params object[] args)
|
||||
{
|
||||
udpSender = new UDPSender(Address, Port);
|
||||
udpSender.Send(new OscMessage(address, args));
|
||||
udpSender.Close();
|
||||
}
|
||||
public void sendAndReceiveString(string address)
|
||||
{
|
||||
try
|
||||
{
|
||||
tcpSender.SendAndReceive(new OscMessage(address));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("QCLIENT - Send and Receive Exception: " + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void sendAndReceiveStringArgs(string address, params object[] args)
|
||||
{
|
||||
try
|
||||
{
|
||||
tcpSender.SendAndReceive(new OscMessage(address, args));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("QCLIENT - Send and Receive w/Args Exception: " + ex.Message);
|
||||
Log.Debug("QCLIENT - Send and Receive w/Args Exception: " + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void ProcessUpdate(OscMessage msg)
|
||||
{
|
||||
Console.WriteLine("QCLIENT - Process Update: " + msg.Address);
|
||||
Log.Debug("QCLIENT - Process Update: " + msg.Address);
|
||||
if (msg.Address.Contains("workspace"))
|
||||
{
|
||||
UpdateWorkspace("not yet implemented");
|
||||
@@ -120,19 +117,19 @@ namespace qController
|
||||
{
|
||||
string valuesForKeys = "[\"number\",\"uniqueID\",\"flagged\",\"listName\",\"type\",\"colorName\",\"name\",\"armed\",\"displayName\",\"isBroken\",\"isLoaded\",\"isPaused\",\"isRunning\",\"preWait\",\"duration\",\"postWait\",\"translationX\",\"translationY\",\"opacity\",\"scaleX\",\"scaleY\",\"notes\",\"levels\"]";
|
||||
string address = "/workspace/" + workspace_id + "/cue_id/" + cue_id + "/valuesForKeys";
|
||||
sendAndReceiveStringArgs(address, valuesForKeys);
|
||||
sendTCP(address, valuesForKeys);
|
||||
}
|
||||
|
||||
public void UpdateSelectedCue(string workspace_id)
|
||||
{
|
||||
string valuesForKeys = "[\"number\",\"uniqueID\",\"flagged\",\"listName\",\"type\",\"colorName\",\"name\",\"armed\",\"displayName\",\"isBroken\",\"isLoaded\",\"isPaused\",\"isRunning\",\"preWait\",\"duration\",\"postWait\",\"translationX\",\"translationY\",\"opacity\",\"scaleX\",\"scaleY\",\"notes\",\"levels\"]";
|
||||
string address = "/workspace/" + workspace_id + "/cue/selected/valuesForKeys";
|
||||
sendAndReceiveStringArgs(address, valuesForKeys);
|
||||
sendTCP(address, valuesForKeys);
|
||||
}
|
||||
|
||||
public void UpdateWorkspace(string ws_id)
|
||||
{
|
||||
Console.WriteLine("QCLIENT - Workspace needs to be updated: " + ws_id);
|
||||
Log.Debug("QCLIENT - Workspace needs to be updated: " + ws_id);
|
||||
}
|
||||
|
||||
public void Close()
|
||||
|
||||
Reference in New Issue
Block a user