Skip to content
Snippets Groups Projects
Select Git revision
  • 4fef1f7f786291651afdac3728743e40d48a0604
  • main default protected
  • development
  • integration
  • v1.1.5
  • v1.1.4
  • v1.1.3
  • v1.1.2
  • v1.1.1
  • v1.1.0
  • v1.0.0
11 results

RestlikeMessage.swift

Blame
  • BroadcastMessage.swift 664 B
    import Foundation
    
    public struct BroadcastMessage: Equatable {
      public init(
        roundId: Int,
        ephId: [Int],
        payload: Data
      ) {
        self.roundId = roundId
        self.ephId = ephId
        self.payload = payload
      }
    
      public var roundId: Int
      public var ephId: [Int]
      public var payload: Data
    }
    
    extension BroadcastMessage: Codable {
      enum CodingKeys: String, CodingKey {
        case roundId = "RoundID"
        case ephId = "EphID"
        case payload = "Payload"
      }
    
      public static func decode(_ data: Data) throws -> Self {
        try JSONDecoder().decode(Self.self, from: data)
      }
    
      public func encode() throws -> Data {
        try JSONEncoder().encode(self)
      }
    }