MCPcopy Index your code
hub / github.com/coder/websocket / newChatServer

Function newChatServer

internal/examples/chat/chat.go:44–56  ·  view source on GitHub ↗

newChatServer constructs a chatServer with the defaults.

()

Source from the content-addressed store, hash-verified

42
43// newChatServer constructs a chatServer with the defaults.
44func newChatServer() *chatServer {
45 cs := &chatServer{
46 subscriberMessageBuffer: 16,
47 logf: log.Printf,
48 subscribers: make(map[*subscriber]struct{}),
49 publishLimiter: rate.NewLimiter(rate.Every(time.Millisecond*100), 8),
50 }
51 cs.serveMux.Handle("/", http.FileServer(http.Dir(".")))
52 cs.serveMux.HandleFunc("/subscribe", cs.subscribeHandler)
53 cs.serveMux.HandleFunc("/publish", cs.publishHandler)
54
55 return cs
56}
57
58// subscriber represents a subscriber.
59// Messages are sent on the msgs channel and if the client

Callers 2

setupTestFunction · 0.85
runFunction · 0.85

Calls

no outgoing calls

Tested by 1

setupTestFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…