SendToAgent sends a message to the agent owning the named session. Writes are serialised by the registry's per-agent write mutex.
(sessionID string, msg any)
| 153 | // SendToAgent sends a message to the agent owning the named session. Writes |
| 154 | // are serialised by the registry's per-agent write mutex. |
| 155 | func (s *Sessions) SendToAgent(sessionID string, msg any) error { |
| 156 | s.mu.RLock() |
| 157 | sess, ok := s.sessions[sessionID] |
| 158 | s.mu.RUnlock() |
| 159 | if !ok { |
| 160 | return errors.New("session not found") |
| 161 | } |
| 162 | return sess.sender.SendJSON(sess.ApiID, msg) |
| 163 | } |
| 164 | |
| 165 | func (s *Session) acceptLoop(ctx context.Context) { |
| 166 | for { |
no test coverage detected