Skip to content

Commit c94a805

Browse files
committed
Add ClientID to auth requests so auth server can correlate to entityid later. Also extend Koja types.
1 parent f6a244f commit c94a805

File tree

3 files changed

+32
-12
lines changed

3 files changed

+32
-12
lines changed

Sources/allonet2/Interaction.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public enum InteractionBody : Codable
6060

6161
// - Authentication (App agent to place)
6262
case registerAsAuthenticationProvider // -> .success or .error
63-
case authenticationRequest(identity: Identity) // -> .success or .error
63+
case authenticationRequest(clientId: ClientId, identity: Identity) // -> .success or .error
6464

6565
// - Agent to agent
6666
case tap(at: SIMD3<Float>) // oneway

Sources/allonet2/PlaceServer/PlaceServer+PlaceInteractions.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ extension PlaceServer
7070
}
7171
if requiresAuthenticationProvider || (identity.expectation == .app && !alloAppAuthToken.isEmpty)
7272
{
73-
try await authenticate(identity: identity, in: ilogger)
73+
try await authenticate(identity: identity, from: client.cid, in: ilogger)
7474
}
7575

7676
client.announced = true
@@ -101,7 +101,7 @@ extension PlaceServer
101101
client.session.send(interaction: announce.makeResponse(with: .announceResponse(avatarId: avatar.id, placeName: name)))
102102
}
103103

104-
func authenticate(identity: Identity, in ilogger: Logger) async throws(AlloverseError)
104+
func authenticate(identity: Identity, from cid: ClientId, in ilogger: Logger) async throws(AlloverseError)
105105
{
106106
if identity.expectation == .app
107107
{
@@ -119,7 +119,7 @@ extension PlaceServer
119119

120120
let request = Interaction(type: .request, senderEntityId: Interaction.PlaceEntity,
121121
receiverEntityId: authenticationId,
122-
body: .authenticationRequest(identity: identity))
122+
body: .authenticationRequest(clientId: cid, identity: identity))
123123

124124
let answer = await authenticationProvider.session.request(interaction: request)
125125

Sources/allonet2/StandardComponents.swift

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -226,28 +226,48 @@ public enum PresenceMode: String, Codable, CaseIterable, Identifiable
226226
@MainActor
227227
public struct KojaUser: Codable, Equatable, Identifiable
228228
{
229-
public var id: String
229+
public let id: String
230+
public let avatarId: EntityID
230231
public var displayName: String
231232
public var email: String?
232233
public var presence: PresenceMode
233-
public var avatarId: EntityID
234+
235+
public init(id: String, avatarId: EntityID, displayName: String, email: String?, presence: PresenceMode) {
236+
self.id = id
237+
self.avatarId = avatarId
238+
self.displayName = displayName
239+
self.email = email
240+
self.presence = presence
241+
}
234242
}
235243

236244
@MainActor
237245
public struct KojaRoom: Codable, Equatable, Identifiable
238246
{
239-
public var id: String
240-
public var name: String
241-
public var entity: EntityID
247+
public let id: String
248+
public let name: String
249+
public let entity: EntityID
242250
// TODO: room usage (meeting, team room, etc)
243-
public var users: [KojaUser]
251+
public var users: [KojaUser] = []
252+
253+
public init(id: String, name: String, entity: EntityID) {
254+
self.id = id
255+
self.name = name
256+
self.entity = entity
257+
}
244258
}
245259

246260
@MainActor
247261
public struct KojaPlaceInfo: Component
248262
{
249-
public var users: [KojaUser]
250-
public var rooms: [KojaRoom]
263+
public var rooms: [KojaRoom] = []
264+
public var invisibleUsers: [KojaUser] = []
265+
public var offlineUsers: [KojaUser] = []
266+
public init() {}
267+
268+
public var allUsers: [KojaUser] {
269+
return rooms.flatMap { $0.users } + invisibleUsers + offlineUsers
270+
}
251271
}
252272

253273
// MARK: - Related types

0 commit comments

Comments
 (0)