Skip to content
This repository has been archived by the owner on Jun 28, 2024. It is now read-only.

Commit

Permalink
Remove Peer type alias
Browse files Browse the repository at this point in the history
  • Loading branch information
mironiasty committed Apr 24, 2024
1 parent fd9da01 commit 4375c3e
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ extension ContentViewController: JellyfishClientListener {

func onSendMediaEvent(event: SerializedMediaEvent) {}

func onJoined(peerID: String, peersInRoom: [Peer]) {
func onJoined(peerID: String, peersInRoom: [Endpoint]) {
self.localParticipantId = peerID

let localParticipant = Participant(id: peerID, displayName: "Me", isAudioTrackActive: true)
Expand Down Expand Up @@ -236,22 +236,22 @@ extension ContentViewController: JellyfishClientListener {
}
}

func onPeerJoined(peer: Peer) {
func onPeerJoined(peer: Endpoint) {
self.participants[peer.id] = Participant(
id: peer.id, displayName: peer.metadata["displayName"] as? String ?? "", isAudioTrackActive: false)
let pv =
ParticipantVideo(id: peer.id, participant: participants[peer.id]!, videoTrack: nil, isActive: false)
add(video: pv)
}

func onPeerLeft(peer: Peer) {
func onPeerLeft(peer: Endpoint) {
DispatchQueue.main.async {
self.participants.removeValue(forKey: peer.id)
self.participantVideos = self.participantVideos.filter({ $0.participant.id != peer.id })
}
}

func onPeerUpdated(peer _: Peer) {}
func onPeerUpdated(peer _: Endpoint) {}

func onSocketClose(code: Int, reason: String) {
if code != 1000 || reason == "invalid token" {
Expand Down
8 changes: 4 additions & 4 deletions Sources/JellyfishClientSdk/JellyfishClientInternal.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ internal class JellyfishClientInternal: MembraneRTCDelegate, WebSocketDelegate {
webrtcClient?.receiveMediaEvent(mediaEvent: event)
}

func onEndpointAdded(endpoint: Peer) {
func onEndpointAdded(endpoint: Endpoint) {
listener.onPeerJoined(peer: endpoint)
}

func onEndpointRemoved(endpoint: Peer) {
func onEndpointRemoved(endpoint: Endpoint) {
listener.onPeerLeft(peer: endpoint)
}

func onEndpointUpdated(endpoint: Peer) {
func onEndpointUpdated(endpoint: Endpoint) {
listener.onPeerUpdated(peer: endpoint)
}

Expand Down Expand Up @@ -155,7 +155,7 @@ internal class JellyfishClientInternal: MembraneRTCDelegate, WebSocketDelegate {
listener.onDisconnected()
}

func onConnected(endpointId: String, otherEndpoints: [Peer]) {
func onConnected(endpointId: String, otherEndpoints: [Endpoint]) {
listener.onJoined(peerID: endpointId, peersInRoom: otherEndpoints)
}

Expand Down
8 changes: 4 additions & 4 deletions Sources/JellyfishClientSdk/JellyfishClientListener.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public protocol JellyfishClientListener {
/**
* Called when peer was accepted.
*/
func onJoined(peerID: String, peersInRoom: [Peer])
func onJoined(peerID: String, peersInRoom: [Endpoint])

/**
* Called when peer was not accepted
Expand All @@ -44,17 +44,17 @@ public protocol JellyfishClientListener {
/**
* Called each time new peer joins the room.
*/
func onPeerJoined(peer: Peer)
func onPeerJoined(peer: Endpoint)

/**
* Called each time peer leaves the room.
*/
func onPeerLeft(peer: Peer)
func onPeerLeft(peer: Endpoint)

/**
* Called each time peer has its metadata updated.
*/
func onPeerUpdated(peer: Peer)
func onPeerUpdated(peer: Endpoint)

/**
* Called when data in a new track arrives.
Expand Down
2 changes: 1 addition & 1 deletion Sources/JellyfishClientSdk/JellyfishTrackContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ public class JellyfishTrackContext {

public var track: RemoteTrack? { return trackContext.track }

public var peer: Peer { return trackContext.endpoint }
public var peer: Endpoint { return trackContext.endpoint }

public var trackId: String { return trackContext.trackId }

Expand Down
1 change: 0 additions & 1 deletion Sources/JellyfishClientSdk/JellyfishTypes.swift

This file was deleted.

0 comments on commit 4375c3e

Please sign in to comment.