MCPcopy
hub / github.com/tinode/chat / sendMessage

Method sendMessage

server/hdl_websock.go:67–82  ·  view source on GitHub ↗
(msg any)

Source from the content-addressed store, hash-verified

65}
66
67func (sess *Session) sendMessage(msg any) bool {
68 if len(sess.send) > sendQueueLimit {
69 logs.Err.Println("ws: outbound queue limit exceeded", sess.sid)
70 return false
71 }
72
73 statsInc("OutgoingMessagesWebsockTotal", 1)
74 if err := wsWrite(sess.ws, websocket.TextMessage, msg); err != nil {
75 if websocket.IsUnexpectedCloseError(err, websocket.CloseGoingAway, websocket.CloseAbnormalClosure,
76 websocket.CloseNormalClosure) {
77 logs.Err.Println("ws: writeLoop", sess.sid, err)
78 }
79 return false
80 }
81 return true
82}
83
84func (sess *Session) writeLoop() {
85 ticker := time.NewTicker(pingPeriod)

Callers 1

writeLoopMethod · 0.95

Calls 3

statsIncFunction · 0.85
wsWriteFunction · 0.85
PrintlnMethod · 0.80

Tested by

no test coverage detected