From b02e9677617d02a24ef60371e35fa0a9852e7c17 Mon Sep 17 00:00:00 2001 From: Elijah R Date: Sun, 23 Jun 2024 14:02:22 -0400 Subject: [PATCH] add country code support and bump ver --- CollabVMSharp/CollabVMClient.cs | 20 +++++++++++++++++++- CollabVMSharp/CollabVMSharp.csproj | 2 +- CollabVMSharp/User.cs | 1 + 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/CollabVMSharp/CollabVMClient.cs b/CollabVMSharp/CollabVMClient.cs index b54128f..ab7156d 100644 --- a/CollabVMSharp/CollabVMClient.cs +++ b/CollabVMSharp/CollabVMClient.cs @@ -90,6 +90,11 @@ public class CollabVMClient { /// Fired when the client encounters a non-fatal error /// public event EventHandler Error; + + /// + /// Fired when the server sends a user's country code + /// + public event EventHandler CountryCodeUpdated; /// /// Client for the CollabVM 1.x Server /// @@ -165,6 +170,7 @@ public class CollabVMClient { ConnectionClosed += delegate { }; VMUsesAccountAuth += delegate { }; Error += delegate { }; + CountryCodeUpdated += delegate { }; } /// /// Connect to the CollabVM Server @@ -485,7 +491,8 @@ public class CollabVMClient { break; } - case "admin": { + case "admin": + { switch (msgArr[1]) { case "0": { switch (msgArr[2]) { @@ -517,6 +524,17 @@ public class CollabVMClient { } break; } + case "flag": + { + for (int i = 1; i < msgArr.Length; i += 2) + { + var user = this._users.Find(u => u.Username == msgArr[i]); + if (user == null) continue; + user.CountryCode = msgArr[i + 1]; + this.CountryCodeUpdated.Invoke(this, user); + } + break; + } } } /// diff --git a/CollabVMSharp/CollabVMSharp.csproj b/CollabVMSharp/CollabVMSharp.csproj index 7822f79..dde44d2 100644 --- a/CollabVMSharp/CollabVMSharp.csproj +++ b/CollabVMSharp/CollabVMSharp.csproj @@ -3,7 +3,7 @@ net6.0 10 - 2.6.0 + 2.7.0 True GPL-3.0-or-later README.md diff --git a/CollabVMSharp/User.cs b/CollabVMSharp/User.cs index 7c0a0a1..011884f 100644 --- a/CollabVMSharp/User.cs +++ b/CollabVMSharp/User.cs @@ -2,6 +2,7 @@ namespace CollabVMSharp; public class User { public string Username { get; set; } + public string? CountryCode { get; set; } public Rank Rank { get; set; } public TurnStatus Turn { get; set; } } \ No newline at end of file