MCPcopy Create free account
hub / github.com/tiann/hapi / recordSessionActivity

Method recordSessionActivity

hub/src/sync/sessionCache.ts:325–357  ·  view source on GitHub ↗
(sessionId: string, updatedAt: number)

Source from the content-addressed store, hash-verified

323 }
324
325 recordSessionActivity(sessionId: string, updatedAt: number): void {
326 if (!Number.isFinite(updatedAt)) {
327 return
328 }
329
330 const stored = this.store.sessions.getSession(sessionId)
331 if (!stored) {
332 return
333 }
334
335 const nextUpdatedAt = Math.max(stored.updatedAt, updatedAt)
336 const touched = this.store.sessions.touchSessionUpdatedAt(sessionId, nextUpdatedAt, stored.namespace)
337 const session = this.sessions.get(sessionId)
338
339 if (!session) {
340 if (touched) {
341 this.refreshSession(sessionId)
342 }
343 return
344 }
345
346 if (nextUpdatedAt <= session.updatedAt && !touched) {
347 return
348 }
349
350 session.updatedAt = Math.max(session.updatedAt, nextUpdatedAt)
351 this.publisher.emit({
352 type: 'session-updated',
353 sessionId,
354 namespace: session.namespace,
355 data: { updatedAt: session.updatedAt } satisfies SessionPatch
356 })
357 }
358
359 handleSessionEnd(payload: { sid: string; time: number }): void {
360 const t = clampAliveTime(payload.time) ?? Date.now()

Callers

nothing calls this directly

Calls 5

refreshSessionMethod · 0.95
touchSessionUpdatedAtMethod · 0.80
getMethod · 0.80
getSessionMethod · 0.45
emitMethod · 0.45

Tested by

no test coverage detected