]> git.deb.at Git - rhonda/impostor.git/commitdiff
Packet recorder add disconnect reason
authorAeonLucid <aeonlucid@outlook.com>
Sun, 1 Nov 2020 20:08:54 +0000 (21:08 +0100)
committerAeonLucid <aeonlucid@outlook.com>
Sun, 1 Nov 2020 20:08:54 +0000 (21:08 +0100)
src/Impostor.Server/Recorder/ClientRecorder.cs
src/Impostor.Server/Recorder/PacketRecorder.cs
src/Impostor.Tools.ServerReplay/Program.cs

index 94b320edc85e2deaef3ef1601279aff938d88e5f..03ad965fc0381c10eb5a4348f2919b9d5da7abc2 100644 (file)
@@ -79,8 +79,8 @@ namespace Impostor.Server.Recorder
 
         public override async ValueTask HandleDisconnectAsync(string reason)
         {
-            await _recorder.WriteDisconnectAsync(this);
+            await _recorder.WriteDisconnectAsync(this, reason);
             await base.HandleDisconnectAsync(reason);
         }
     }
-}
\ No newline at end of file
+}
index 652496c34eeefda89f89d8494b9954bcac183c8e..f3ff48b60017f7e342bcd0cf08bc3b92bfd0796e 100644 (file)
@@ -55,7 +55,7 @@ namespace Impostor.Server.Recorder
             }
         }
 
-        public async Task WriteDisconnectAsync(ClientRecorder client)
+        public async Task WriteDisconnectAsync(ClientRecorder client, string reason)
         {
             _logger.LogTrace("Writing Disconnect.");
 
@@ -65,6 +65,7 @@ namespace Impostor.Server.Recorder
             {
                 WriteHeader(context, RecordedPacketType.Disconnect);
                 WriteClient(context, client, false);
+                context.Writer.Write(reason);
                 WriteLength(context);
 
                 await WriteAsync(context.Stream);
index af2ffd92fd08d2b42db3adde4d470f8420913797..f6568016bdbfb78a88e593e21d1e3f8674731243 100644 (file)
@@ -146,7 +146,14 @@ namespace Impostor.Tools.ServerReplay
                     break;
 
                 case RecordedPacketType.Disconnect:
-                    await Connections[clientId].Client!.HandleDisconnectAsync(null);
+                    string reason = null;
+
+                    if (reader.BaseStream.Position < reader.BaseStream.Length)
+                    {
+                        reason = reader.ReadString();
+                    }
+
+                    await Connections[clientId].Client!.HandleDisconnectAsync(reason);
                     Connections.Remove(clientId);
                     break;