Skip to content

Commit 8d92a8d

Browse files
chripoAndrewBurian
authored andcommitted
Added NumClients to stream object
1 parent 5e78397 commit 8d92a8d

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

stream.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,11 @@ func (s *Stream) ClientConnectHook(fn func(*http.Request, *Client)) {
219219
s.clientConnectHook = fn
220220
}
221221

222+
// NumClients returns the number of currently connected clients
223+
func (s *Stream) NumClients() int {
224+
return len(s.clients)
225+
}
226+
222227
// Checks that a client expects an event-stream
223228
func checkRequest(r *http.Request) bool {
224229
return r.Header.Get("Accept") == "text/event-stream"

0 commit comments

Comments
 (0)