JoinRejectedMessage.cs 1007 B

123456789101112131415161718192021222324252627282930313233343536
  1. using System;
  2. namespace Microsoft.Xna.Framework.Net
  3. {
  4. /// <summary>
  5. /// Message sent by the host to reject a join request.
  6. /// </summary>
  7. public class JoinRejectedMessage : INetworkMessage
  8. {
  9. public byte MessageType => 6;
  10. /// <summary>
  11. /// The reason for the rejection.
  12. /// </summary>
  13. public NetworkSessionJoinError ErrorCode { get; set; }
  14. /// <summary>
  15. /// Human-readable reason for rejection.
  16. /// </summary>
  17. public string Reason { get; set; }
  18. public void Serialize(PacketWriter writer)
  19. {
  20. writer.Write(MessageType);
  21. writer.Write((byte)ErrorCode);
  22. writer.Write(Reason ?? string.Empty);
  23. }
  24. public void Deserialize(PacketReader reader)
  25. {
  26. // Reader is positioned after the type byte
  27. ErrorCode = (NetworkSessionJoinError)reader.ReadByte();
  28. Reason = reader.ReadString();
  29. }
  30. }
  31. }