Skip to content

The onConnect and setNotificationHandler callback should provide the ServerSession #780

@ghostflyby

Description

@ghostflyby

Is your feature request related to a problem? Please describe.
I've been trying to create a reactive listener based on per-session roots notification and found it impossible or wired.

onConnect {
    sessions.forEach { (_, session) ->
        session.setNotificationHandler<RootsListChangedNotification>(Method.Defined.NotificationsRootsListChanged) {
            scope.launch {
                session.listRoots()

                // do Something with roots per session
            }
            CompletableDeferred()
        }
    }
}

I have to reset notifications for all sessions on each new session to properly get the per-session info.

Describe the solution you'd like

onConnect { session : ServerSession -> 
// do something with session
}

or

server.setNotificationHandler<RootsListChangedNotification>(Method.Defined.NotificationsRootsListChanged) {session : ServerSession -> 
// do something with session
}

or both.

Other infos

I suspect that the no-session-arg style onConnect and other callbacks are the legacy of the old new server per transport architecture.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Nice to haves, rare edge casesapiPublic API changesenhancementNew feature or requestready for workHas enough information to start
    No fields configured for Enhancement.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions