aboutsummaryrefslogtreecommitdiff
path: root/Hotline/Models/Server.swift
blob: 495d236314d2c7a8135d1cccdc08383b3ad1db70 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import SwiftUI

@Observable final class Server: Identifiable, Equatable, Hashable, Codable {
  static let defaultPort: Int = 5500
  
  let id: UUID
  let name: String?
  let description: String?
  let users: Int
  let address: String
  let port: Int
  
  init(name: String?, description: String?, address: String, port: Int, users: Int = 0) {
    self.id = UUID()
    self.name = name
    self.description = description
    self.address = address
    self.port = port
    self.users = users
  }
  
  func hash(into hasher: inout Hasher) {
    hasher.combine(self.id)
  }
  
  static func == (lhs: Server, rhs: Server) -> Bool {
    return lhs.id == rhs.id
  }
}