bind implements the binder[*ServerSession] interface, so that Servers can be connected using [connect].
(mcpConn Connection, conn *jsonrpc2.Connection, state *ServerSessionState, onClose func())
| 975 | // bind implements the binder[*ServerSession] interface, so that Servers can |
| 976 | // be connected using [connect]. |
| 977 | func (s *Server) bind(mcpConn Connection, conn *jsonrpc2.Connection, state *ServerSessionState, onClose func()) *ServerSession { |
| 978 | assert(mcpConn != nil && conn != nil, "nil connection") |
| 979 | ss := &ServerSession{conn: conn, mcpConn: mcpConn, server: s, onClose: onClose} |
| 980 | if state != nil { |
| 981 | ss.state = *state |
| 982 | } |
| 983 | s.mu.Lock() |
| 984 | s.sessions = append(s.sessions, ss) |
| 985 | s.mu.Unlock() |
| 986 | s.opts.Logger.Info("server session connected", "session_id", ss.ID()) |
| 987 | return ss |
| 988 | } |
| 989 | |
| 990 | // disconnect implements the binder[*ServerSession] interface, so that |
| 991 | // Servers can be connected using [connect]. |