MCPcopy Create free account
hub / github.com/adalkiran/distributed-inference / serveWs

Method serveWs

signaling/src/signaling/httpserver.go:71–85  ·  view source on GitHub ↗

serveWs handles websocket requests from the peer.

(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

69
70// serveWs handles websocket requests from the peer.
71func (s *HttpServer) serveWs(w http.ResponseWriter, r *http.Request) {
72 upgrader.CheckOrigin = func(r *http.Request) bool { return true }
73 conn, err := upgrader.Upgrade(w, r, nil)
74 if err != nil {
75 logging.Errorf(logging.ProtoHTTP, "Error: %s", err)
76 return
77 }
78 client := &WsClient{wsHub: s.WsHub, conn: conn, send: make(chan []byte, 256), SendMessage: make(chan WsMessageContainer, 256)}
79 client.wsHub.register <- client
80
81 // Allow collection of memory referenced by the caller by doing all work in
82 // new goroutines.
83 go client.writePump()
84 go client.readPump()
85}

Callers 1

NewHttpServerFunction · 0.95

Calls 2

writePumpMethod · 0.95
readPumpMethod · 0.95

Tested by

no test coverage detected