aboutsummaryrefslogtreecommitdiff
path: root/Hotline/Models/Server.swift
blob: b159a1a62dce46c484b274bfac6182f02dab7863 (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
import SwiftUI

@Observable final class Server: Identifiable, Equatable {
  static let defaultPort: Int = 5500
  
  let id: UUID = 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.name = name
    self.description = description
    self.address = address
    self.port = port
    self.users = users
  }
  
  static func == (lhs: Server, rhs: Server) -> Bool {
    return lhs.id == rhs.id
  }
  
  static func == (lhs: HotlineServer, rhs: Server) -> Bool {
    return lhs.name == rhs.name && lhs.address == rhs.address && lhs.port == rhs.port
  }
}