aparently this is a feature now

This commit is contained in:
Elijah R 2024-06-23 13:48:20 -04:00
parent 7f0dc17590
commit 0780098192

View file

@ -85,6 +85,11 @@ public class CollabVMClient {
/// Fired when the VM requires account authentication. The provided string is the authentication server base URL.
/// </summary>
public event EventHandler<string> VMUsesAccountAuth;
/// <summary>
/// Fired when the client encounters a non-fatal error
/// </summary>
public event EventHandler<string> Error;
/// <summary>
/// Client for the CollabVM 1.x Server
/// </summary>
@ -159,6 +164,7 @@ public class CollabVMClient {
TurnUpdate += delegate { };
ConnectionClosed += delegate { };
VMUsesAccountAuth += delegate { };
Error += delegate { };
}
/// <summary>
/// Connect to the CollabVM Server
@ -278,11 +284,22 @@ public class CollabVMClient {
}
case "list": {
List<Node> nodes = new();
for (var i = 1; i < msgArr.Length; i += 3) {
for (var i = 1; i < msgArr.Length; i += 3)
{
byte[] thumbnail;
try
{
thumbnail = Convert.FromBase64String(msgArr[i + 2]);
}
catch (FormatException ex)
{
Error.Invoke(this, "Server sent an invalid thumbnail.");
return;
}
nodes.Add(new Node {
ID = msgArr[i],
Name = msgArr[i+1],
Thumbnail = Convert.FromBase64String(msgArr[i+2])
Thumbnail = thumbnail
});
this.GotNodeList.TrySetResult(nodes.ToArray());
}
@ -299,7 +316,16 @@ public class CollabVMClient {
}
case "png": {
if (msgArr[2] != "0") return;
Image rect = Image.Load(Convert.FromBase64String(msgArr[5]));
Image rect;
try
{
rect = Image.Load(Convert.FromBase64String(msgArr[5]));
}
catch (FormatException ex)
{
Error.Invoke(this, "Server sent an invalid screen rect");
return;
}
framebuffer.Mutate(f => f.DrawImage(rect, new Point(int.Parse(msgArr[3]), int.Parse(msgArr[4])), 1));
this.Rect.Invoke(this, new RectEventArgs {
X = int.Parse(msgArr[3]),