Skip to content

Commit

Permalink
Fix channels being advertised twice to new clients (#9)
Browse files Browse the repository at this point in the history
### Changelog
Fixed an issue where channels were being advertised twice to new
clients.

### Docs

None

### Description

This was happening for both `.preparing` and `.ready` states.

---------

Co-authored-by: Richard Dancsi <[email protected]>
  • Loading branch information
jtbandes and wimagguc authored Jul 2, 2024
1 parent 088b1c1 commit 6fcaf42
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions WebSocketDemo-Shared/FoxgloveServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -134,20 +134,20 @@ class FoxgloveServer: ObservableObject {
connection.stateUpdateHandler = { state in
print("connection state \(state)")

if connection.state == .ready {
if state == .ready {
self.sendInfo(connection)
}

let closed: Bool
switch connection.state {
switch state {
case .cancelled, .failed:
closed = true
default:
closed = false
}

Task { @MainActor in
if !self.channels.isEmpty {
if state == .ready, !self.channels.isEmpty {
try self.sendJson([
"op": "advertise",
"channels": self.channels.values.map {
Expand Down

0 comments on commit 6fcaf42

Please sign in to comment.