2021-11-08 16:39:17 +00:00

23 lines
428 B
Go

// +build !js
package websocket
func (c *Conn) RecordBytesWritten() *int {
var bytesWritten int
c.bw.Reset(writerFunc(func(p []byte) (int, error) {
bytesWritten += len(p)
return c.rwc.Write(p)
}))
return &bytesWritten
}
func (c *Conn) RecordBytesRead() *int {
var bytesRead int
c.br.Reset(readerFunc(func(p []byte) (int, error) {
n, err := c.rwc.Read(p)
bytesRead += n
return n, err
}))
return &bytesRead
}