Skip to content

Commit

Permalink
refactor: any type, not just websocket
Browse files Browse the repository at this point in the history
Signed-off-by: Niall Shaw <[email protected]>
  • Loading branch information
niall-shaw committed Aug 29, 2023
1 parent c460a86 commit e741b6a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/core/src/agent/TransportService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export class TransportService {
public transportSessionTable: TransportSessionTable = {}

public saveSession(session: TransportSession) {
if (session.type === 'WebSocket' && session.connectionId) {
const oldSessions = this.getWebSocketSessionsForConnectionId(session.connectionId)
if (session.connectionId) {
const oldSessions = this.getExistingSessionsForConnectionIdAndType(session.connectionId, session.type)
oldSessions.forEach((oldSession) => {
if (oldSession) {
this.removeSession(oldSession)
Expand Down Expand Up @@ -49,9 +49,9 @@ export class TransportService {
delete this.transportSessionTable[session.id]
}

private getWebSocketSessionsForConnectionId(connectionId: string) {
private getExistingSessionsForConnectionIdAndType(connectionId: string, type: string) {
return Object.values(this.transportSessionTable).filter(
(session) => session?.connectionId === connectionId && session.type === 'WebSocket'
(session) => session?.connectionId === connectionId && session.type === type
)
}
}
Expand Down

0 comments on commit e741b6a

Please sign in to comment.