Some platforms (notable the Microsoft Store version) ask for this before connecting.
--- /dev/null
+using System;
+using Impostor.Api.Games;
+
+namespace Impostor.Api.Net.Messages.C2S
+{
+ public class Message22QueryPlatformIdsC2S
+ {
+ public static void Serialize(IMessageWriter writer)
+ {
+ throw new NotImplementedException();
+ }
+
+ public static void Deserialize(IMessageReader reader, out GameCode gameCode)
+ {
+ gameCode = reader.ReadInt32();
+ }
+ }
+}
--- /dev/null
+using System;
+using System.Collections.Generic;
+using Impostor.Api.Games;
+using Impostor.Api.Innersloth;
+
+namespace Impostor.Api.Net.Messages.S2C
+{
+ public class Message22QueryPlatformIdsS2C
+ {
+ public static void Serialize(IMessageWriter writer, GameCode gameCode, IEnumerable<PlatformSpecificData> playerSpecificDatas)
+ {
+ writer.StartMessage(MessageFlags.QueryPlatformIds);
+ writer.Write(gameCode);
+ foreach (var playerSpecificData in playerSpecificDatas)
+ {
+ playerSpecificData.Serialize(writer);
+ }
+
+ writer.EndMessage();
+ }
+
+ public static void Deserialize(IMessageReader reader)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
using System;
+using System.Linq;
using System.Threading.Tasks;
using Impostor.Api;
using Impostor.Api.Games;
break;
}
+ case MessageFlags.QueryPlatformIds:
+ {
+ Message22QueryPlatformIdsC2S.Deserialize(reader, out var gameCode);
+ await OnQueryPlatformIds(gameCode);
+ break;
+ }
+
default:
if (_customMessageManager.TryGet(flag, out var customRootMessage))
{
return Connection.SendAsync(message);
}
+
+ /// <summary>
+ /// Triggered when the connected client requests the PlatformSpecificData.
+ /// </summary>
+ /// <param name="code">
+ /// The GameCode of the game whose platform id's are checked.
+ /// </param>
+ private ValueTask OnQueryPlatformIds(GameCode code)
+ {
+ using var message = MessageWriter.Get(MessageType.Reliable);
+
+ var playerSpecificData = _gameManager.Find(code)?.Players.Select(p => p.Client.PlatformSpecificData) ?? Enumerable.Empty<PlatformSpecificData>();
+
+ Message22QueryPlatformIdsS2C.Serialize(message, code, playerSpecificData);
+
+ return Connection.SendAsync(message);
+ }
}
}