### Create Jellyfin Client and Sign In Source: https://github.com/jellyfin/jellyfin-sdk-swift/blob/main/README.md Instantiate the JellyfinClient and authenticate a user with their username and password. This client handles authorization headers and date decoding. ```swift let jellyfinClient = JellyfinClient(configuration: configuration) let response = jellyfinClient.signIn(username: "jelly", password: "fin") ``` -------------------------------- ### Open WebSocket Session and Subscribe to Events Source: https://github.com/jellyfin/jellyfin-sdk-swift/blob/main/README.md Establishes a WebSocket connection for real-time updates. Allows subscribing to various event feeds like sessions and activity logs with optional intervals. Events are delivered as a stream. ```swift let session = client.socket( supportsMediaControl: true, supportedCommands: [.displayMessage, .play, .pause] ).connect() session.subscribe(.sessions) session.subscribe(.activityLog, interval: .seconds(10)) for try await event in session.events { switch event { case .connecting: print("Connecting...") case let .connected(url): print("Connected to \(url)") case let .message(message): switch message { case let .sessionsMessage(msg): print("Sessions: \(msg)") default: break } } } session.unsubscribe(.activityLog) session.disconnect() ``` -------------------------------- ### Update OpenAPI Specification Source: https://github.com/jellyfin/jellyfin-sdk-swift/blob/main/README.md Downloads the latest OpenAPI specification and runs the CreateAPI tool. This is a build-related command. ```bash # Download latest spec and run CreateAPI $ make update ``` -------------------------------- ### Discover Jellyfin Servers on Local Network Source: https://github.com/jellyfin/jellyfin-sdk-swift/blob/main/README.md Scans the local network for Jellyfin servers using UDP broadcast over IPv4. Returns discovered server details including name and URL within a specified duration. ```swift for try await server in JellyfinClient.discover(duration: .seconds(5)) { print("Found server: \(server.name) at \(server.url)") } ``` -------------------------------- ### Quick Connect Authentication Flow Source: https://github.com/jellyfin/jellyfin-sdk-swift/blob/main/README.md Implements the Quick Connect authorization flow. It polls for connection states and proceeds to authenticate using a received secret upon successful connection. ```swift for try await state in client.quickConnect.connect() { switch state { case let .polling(code: code): print("Code: \(code)") case let .authenticated(secret: secret): try await client.signIn(quickConnectSecret: secret) } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.