mirror of
https://github.com/jwetzell/qController.git
synced 2026-08-20 22:49:24 +00:00
Update Encoding for special characters
This commit is contained in:
@@ -12,7 +12,6 @@ namespace qController
|
||||
UDPSender udpSender;
|
||||
public QParser qParser;
|
||||
public QReceiver qReceiver;
|
||||
|
||||
string Address;
|
||||
int Port;
|
||||
|
||||
@@ -23,7 +22,7 @@ namespace qController
|
||||
qParser = new QParser();
|
||||
qReceiver = new QReceiver(Port + 1);
|
||||
tcpSender = new TCPSender(Address, Port);
|
||||
udpSender = new UDPSender(Address, Port);
|
||||
//udpSender = new UDPSender(Address, Port);
|
||||
|
||||
tcpSender.MessageReceived += OnMessageReceived;
|
||||
qReceiver.UpdateMessageReceived += OnMessageReceived;
|
||||
@@ -33,7 +32,7 @@ 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);
|
||||
Console.WriteLine("QCLIENT - Message Received: " + args.Message.Address);
|
||||
//try to find a better filtering process
|
||||
if (!args.Message.Address.Contains("update"))
|
||||
qParser.ParseMessage(args.Message);
|
||||
@@ -56,7 +55,7 @@ namespace qController
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("SEND EXCEPTION: " + ex.Message);
|
||||
Console.WriteLine("QCLIENT - Send Exception: " + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +67,7 @@ namespace qController
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("SEND ARGS EXCEPTION: " + ex.Message);
|
||||
Console.WriteLine("QCLIENT - Send w/Args Exception: " + ex.Message);
|
||||
}
|
||||
}
|
||||
public void sendStringUDP(string address)
|
||||
@@ -91,7 +90,7 @@ namespace qController
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("SEND AND RECIEVE EXCEPTION: " + ex.Message);
|
||||
Console.WriteLine("QCLIENT - Send and Receive Exception: " + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,14 +102,14 @@ namespace qController
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("SEND AND RECEIVE ARGS EXCEPTION: " + ex.Message);
|
||||
Console.WriteLine("QCLIENT - Send and Receive w/Args Exception: " + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void ProcessUpdate(OscMessage msg)
|
||||
{
|
||||
Console.WriteLine("PROCESS UPDATE : " + msg.Address);
|
||||
Console.WriteLine("QCLIENT - Process Update: " + msg.Address);
|
||||
if (msg.Address.Contains("workspace"))
|
||||
{
|
||||
UpdateWorkspace("not yet implemented");
|
||||
@@ -133,7 +132,7 @@ namespace qController
|
||||
|
||||
public void UpdateWorkspace(string ws_id)
|
||||
{
|
||||
Console.WriteLine("Workspace needs to be updated: " + ws_id);
|
||||
Console.WriteLine("QCLIENT - Workspace needs to be updated: " + ws_id);
|
||||
}
|
||||
|
||||
public void Close()
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace qController
|
||||
|
||||
public void Connect(string workspace_id)
|
||||
{
|
||||
Console.WriteLine("QCONTROLLER CONNECT CALLED: " + workspace_id);
|
||||
Console.WriteLine("QCONTROLLER - Connect Called: " + workspace_id);
|
||||
qWorkspace = new QWorkspace(workspace_id);
|
||||
qUpdater.Start();
|
||||
qClient.sendArgsUDP("/workspace/"+workspace_id+"/connect");
|
||||
@@ -58,7 +58,7 @@ namespace qController
|
||||
//qUpdater = new QUpdater(this);
|
||||
if(qWorkspace != null)
|
||||
{
|
||||
Console.WriteLine("RESUMING " + qWorkspace.workspace_id);
|
||||
Console.WriteLine("QCONTROLLER - Resuming: " + qWorkspace.workspace_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,12 +14,9 @@ namespace qController
|
||||
|
||||
public async void SearchForWorkspaces()
|
||||
{
|
||||
|
||||
Console.WriteLine("QFINDER - Scanning Started");
|
||||
IReadOnlyList<IZeroconfHost> results = await ZeroconfResolver.ResolveAsync("_qlab._udp.local.");
|
||||
foreach (var result in results){
|
||||
Console.WriteLine(result.IPAddress);
|
||||
}
|
||||
Console.WriteLine("Done");
|
||||
Console.WriteLine("QFINDER - Scanning Done");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ using SharpOSC;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace qController
|
||||
{
|
||||
public class CueEventArgs : EventArgs
|
||||
@@ -69,7 +68,7 @@ namespace qController
|
||||
{
|
||||
public QParser()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public delegate void SelectedCueUpdatedHandler(object source, CueEventArgs args);
|
||||
@@ -103,7 +102,7 @@ namespace qController
|
||||
else if (msg.Address.Contains("playbackPosition"))
|
||||
ParsePositionUpdateInfo(msg);
|
||||
else if (msg.Address.Contains("thump"))
|
||||
Console.WriteLine("Heartbeat Received");
|
||||
Console.WriteLine("QPARSER - Heartbeat Received");
|
||||
else if (msg.Address.Contains("disconnect"))
|
||||
OnWorkspaceDisconnect();
|
||||
else if (msg.Address.Contains("connect"))
|
||||
@@ -114,7 +113,7 @@ namespace qController
|
||||
ParseQInfo(msg);
|
||||
else
|
||||
{
|
||||
Console.WriteLine("QParser/Unknown message type: " + msg.Address);
|
||||
Console.WriteLine("QPARSER - Unkown message type: " + msg.Address);
|
||||
foreach (var item in msg.Arguments)
|
||||
{
|
||||
Console.WriteLine(item);
|
||||
@@ -171,9 +170,6 @@ namespace qController
|
||||
{
|
||||
try
|
||||
{
|
||||
Console.WriteLine(msg.Arguments.Count);
|
||||
Console.WriteLine(msg.Arguments[0].ToString().Length);
|
||||
|
||||
QWorkspace workspace = JsonConvert.DeserializeObject<QWorkspace>(msg.Arguments[0].ToString());
|
||||
OnWorkspaceUpdated(workspace);
|
||||
}
|
||||
@@ -181,7 +177,6 @@ namespace qController
|
||||
{
|
||||
OnWorkspaceLoadError(id);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//Class used for receiving workspace update messages
|
||||
//Class used for receiving workspace update messages (UDP)
|
||||
using SharpOSC;
|
||||
using System.Threading;
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace qController
|
||||
|
||||
private void OnWorkspaceLoadError(object source, WorkspaceEventArgs args)
|
||||
{
|
||||
Console.WriteLine("QUpdater: Loading cuelists has failed for some reason retrying");
|
||||
Console.WriteLine("QUPDATER - Loading cuelists has failed for some reason retrying");
|
||||
qController.qClient.sendArgsUDP("/workspace/" + args.UpdatedWorkspace.workspace_id + "/connect");
|
||||
qController.qClient.sendArgsUDP("/workspace/" + args.UpdatedWorkspace.workspace_id + "/updates", 1);
|
||||
qController.qClient.sendAndReceiveString("/workspace/" + args.UpdatedWorkspace.workspace_id + "/cueLists");
|
||||
@@ -63,7 +63,7 @@ namespace qController
|
||||
qController.qWorkspace.CheckPopulated();
|
||||
if (qController.qWorkspace.IsPopulated)
|
||||
{
|
||||
Console.WriteLine("Workspace group cues are already populated");
|
||||
Console.WriteLine("QUPDATER - Workspace group cues are already populated");
|
||||
App.showToast("Workspace cues have been loaded....");
|
||||
//get selected cue
|
||||
qController.qClient.UpdateSelectedCue(qController.qWorkspace.workspace_id);
|
||||
@@ -74,12 +74,13 @@ namespace qController
|
||||
public void OnPlaybackPositionUpdated(object source, PlaybackPositionArgs args)
|
||||
{
|
||||
qController.playbackPosition = args.PlaybackPosition;
|
||||
Console.WriteLine("ControlPage: Update Specific Cue Called because of Playback Position Updated");
|
||||
Console.WriteLine("QUPDATER - Update Specific Cue Called because of Playback Position Updated");
|
||||
qController.qClient.UpdateSpecificCue(qController.qWorkspace.workspace_id,args.PlaybackPosition);
|
||||
}
|
||||
|
||||
public void SendThump()
|
||||
{
|
||||
|
||||
qController.qClient.sendStringUDP("/workspace/" + qController.qWorkspace.workspace_id + "/thump");
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace SharpOSC
|
||||
|
||||
int i = 0;
|
||||
byte[] output = new byte[len];
|
||||
Encoding.ASCII.GetBytes(bundle).CopyTo(output, i);
|
||||
Encoding.UTF8.GetBytes(bundle).CopyTo(output, i);
|
||||
i += bundleTagLen;
|
||||
tag.CopyTo(output, i);
|
||||
i += tag.Length;
|
||||
|
||||
@@ -142,10 +142,10 @@ namespace SharpOSC
|
||||
byte[] output = new byte[total];
|
||||
i = 0;
|
||||
|
||||
Encoding.ASCII.GetBytes(Address).CopyTo(output, i);
|
||||
Encoding.UTF8.GetBytes(Address).CopyTo(output, i);
|
||||
i += addressLen;
|
||||
|
||||
Encoding.ASCII.GetBytes(typeString).CopyTo(output, i);
|
||||
Encoding.UTF8.GetBytes(typeString).CopyTo(output, i);
|
||||
i += typeLen;
|
||||
|
||||
foreach (byte[] part in parts)
|
||||
|
||||
@@ -27,8 +27,9 @@ namespace SharpOSC
|
||||
private static OscMessage parseMessage(byte[] msg)
|
||||
{
|
||||
int index = 0;
|
||||
//Console.WriteLine("Raw OSC DATA: " + System.Text.Encoding.ASCII.GetString(msg));
|
||||
string address = null;
|
||||
//Console.WriteLine("Raw ASCII DATA: " + System.Text.Encoding.ASCII.GetString(msg));
|
||||
//Console.WriteLine("Raw UTF-8 DATA: " + System.Text.Encoding.UTF8.GetString(msg));
|
||||
string address = null;
|
||||
char[] types = new char[0];
|
||||
List<object> arguments = new List<object>();
|
||||
List<object> mainArray = arguments; // used as a reference when we are parsing arrays to get the main array back
|
||||
@@ -178,7 +179,7 @@ namespace SharpOSC
|
||||
|
||||
int index = 0;
|
||||
|
||||
var bundleTag = Encoding.ASCII.GetString(bundle.SubArray(0, 8));
|
||||
var bundleTag = Encoding.UTF8.GetString(bundle.SubArray(0, 8));
|
||||
index += 8;
|
||||
|
||||
timetag = getULong(bundle, index);
|
||||
@@ -221,7 +222,7 @@ namespace SharpOSC
|
||||
if (i == 0)
|
||||
return "";
|
||||
|
||||
address = Encoding.ASCII.GetString(msg.SubArray(index, i - 1));
|
||||
address = Encoding.UTF8.GetString(msg.SubArray(index, i - 1));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -241,7 +242,7 @@ namespace SharpOSC
|
||||
{
|
||||
if (msg[i - 1] == 0)
|
||||
{
|
||||
types = Encoding.ASCII.GetChars(msg.SubArray(index, i - index));
|
||||
types = Encoding.UTF8.GetChars(msg.SubArray(index, i - index));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -249,7 +250,7 @@ namespace SharpOSC
|
||||
if (types == null)
|
||||
{
|
||||
byte[] term = { 0 };
|
||||
types = Encoding.ASCII.GetChars(term);
|
||||
types = Encoding.UTF8.GetChars(term);
|
||||
}
|
||||
|
||||
if (i >= msg.Length && types == null)
|
||||
@@ -283,14 +284,14 @@ namespace SharpOSC
|
||||
{
|
||||
if (msg[i - 1] == 0)
|
||||
{
|
||||
output = Encoding.ASCII.GetString(msg.SubArray(index, i - index));
|
||||
output = Encoding.UTF8.GetString(msg.SubArray(index, i - index));
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (output == null)
|
||||
{
|
||||
byte[] term = { 0 };
|
||||
output = Encoding.ASCII.GetString(term);
|
||||
output = Encoding.UTF8.GetString(term);
|
||||
}
|
||||
if (i >= msg.Length && output == null)
|
||||
throw new Exception("No null terminator after type string");
|
||||
@@ -395,7 +396,7 @@ namespace SharpOSC
|
||||
|
||||
byte[] msg = new byte[len];
|
||||
|
||||
var bytes = Encoding.ASCII.GetBytes(value);
|
||||
var bytes = Encoding.UTF8.GetBytes(value);
|
||||
bytes.CopyTo(msg, 0);
|
||||
|
||||
return msg;
|
||||
|
||||
@@ -75,15 +75,15 @@ namespace SharpOSC
|
||||
bytesRead = await netStream.ReadAsync(buffer, 0, buffer.Length);
|
||||
responseData.AddRange(buffer);
|
||||
Thread.Sleep(1);
|
||||
//Console.WriteLine( "Thread " + num + ": Bytes read: " + bytesRead + " - " + Encoding.ASCII.GetString(buffer));
|
||||
//Console.WriteLine( "Thread " + num + ": Bytes read: " + bytesRead + " - " + Encoding.UTF8.GetString(buffer));
|
||||
} while (netStream.DataAvailable);
|
||||
|
||||
//Console.WriteLine("Raw TCP In: " + System.Text.Encoding.ASCII.GetString(responseData.ToArray()));
|
||||
//Console.WriteLine("Raw TCP In: " + System.Text.Encoding.UTF8.GetString(responseData.ToArray()));
|
||||
response = (OscMessage)OscPacket.GetPacket(responseData.Skip(1).ToArray());
|
||||
}
|
||||
} catch(Exception e)
|
||||
{
|
||||
Console.WriteLine("RECEIVE EXCEPTION: " + e.ToString());
|
||||
Console.WriteLine("TCPSENDER - Receive Exception: " + e.ToString());
|
||||
}
|
||||
OnMessageReceived(response);
|
||||
}
|
||||
@@ -101,7 +101,7 @@ namespace SharpOSC
|
||||
public void SendAndReceive(OscPacket packet)
|
||||
{
|
||||
OscMessage msg = (OscMessage)packet;
|
||||
//Console.WriteLine("TCP Message Sent: " + msg.Address);
|
||||
//Console.WriteLine("TCPSENDER - TCP Message Sent: " + msg.Address);
|
||||
byte[] data = packet.GetBytes();
|
||||
SendAndReceive(data);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user