add country code support and bump ver

This commit is contained in:
Elijah R 2024-06-23 14:02:22 -04:00
parent 0780098192
commit b02e967761
3 changed files with 21 additions and 2 deletions

View file

@ -90,6 +90,11 @@ public class CollabVMClient {
/// Fired when the client encounters a non-fatal error /// Fired when the client encounters a non-fatal error
/// </summary> /// </summary>
public event EventHandler<string> Error; public event EventHandler<string> Error;
/// <summary>
/// Fired when the server sends a user's country code
/// </summary>
public event EventHandler<User> CountryCodeUpdated;
/// <summary> /// <summary>
/// Client for the CollabVM 1.x Server /// Client for the CollabVM 1.x Server
/// </summary> /// </summary>
@ -165,6 +170,7 @@ public class CollabVMClient {
ConnectionClosed += delegate { }; ConnectionClosed += delegate { };
VMUsesAccountAuth += delegate { }; VMUsesAccountAuth += delegate { };
Error += delegate { }; Error += delegate { };
CountryCodeUpdated += delegate { };
} }
/// <summary> /// <summary>
/// Connect to the CollabVM Server /// Connect to the CollabVM Server
@ -485,7 +491,8 @@ public class CollabVMClient {
break; break;
} }
case "admin": { case "admin":
{
switch (msgArr[1]) { switch (msgArr[1]) {
case "0": { case "0": {
switch (msgArr[2]) { switch (msgArr[2]) {
@ -517,6 +524,17 @@ public class CollabVMClient {
} }
break; 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;
}
} }
} }
/// <summary> /// <summary>

View file

@ -3,7 +3,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<LangVersion>10</LangVersion> <LangVersion>10</LangVersion>
<Version>2.6.0</Version> <Version>2.7.0</Version>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild> <GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<PackageLicenseExpression>GPL-3.0-or-later</PackageLicenseExpression> <PackageLicenseExpression>GPL-3.0-or-later</PackageLicenseExpression>
<PackageReadmeFile>README.md</PackageReadmeFile> <PackageReadmeFile>README.md</PackageReadmeFile>

View file

@ -2,6 +2,7 @@ namespace CollabVMSharp;
public class User { public class User {
public string Username { get; set; } public string Username { get; set; }
public string? CountryCode { get; set; }
public Rank Rank { get; set; } public Rank Rank { get; set; }
public TurnStatus Turn { get; set; } public TurnStatus Turn { get; set; }
} }