ServerBinaryAckMessage.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using SocketIOClient.Transport;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Text.Json;
  5. namespace SocketIOClient.Messages
  6. {
  7. /// <summary>
  8. /// The client calls the server's callback with binary
  9. /// </summary>
  10. public class ServerBinaryAckMessage : IMessage
  11. {
  12. public MessageType Type => MessageType.BinaryAckMessage;
  13. public string Namespace { get; set; }
  14. public List<JsonElement> JsonElements { get; set; }
  15. public string Json { get; set; }
  16. public int Id { get; set; }
  17. public int BinaryCount { get; }
  18. public int Eio { get; set; }
  19. public TransportProtocol Protocol { get; set; }
  20. public List<byte[]> OutgoingBytes { get; set; }
  21. public List<byte[]> IncomingBytes { get; set; }
  22. public void Read(string msg)
  23. {
  24. }
  25. public string Write()
  26. {
  27. var builder = new StringBuilder();
  28. builder
  29. .Append("46")
  30. .Append(OutgoingBytes.Count)
  31. .Append('-');
  32. if (!string.IsNullOrEmpty(Namespace))
  33. {
  34. builder.Append(Namespace).Append(',');
  35. }
  36. builder.Append(Id);
  37. if (string.IsNullOrEmpty(Json))
  38. {
  39. builder.Append("[]");
  40. }
  41. else
  42. {
  43. builder.Append(Json);
  44. }
  45. return builder.ToString();
  46. }
  47. }
  48. }