23 lines
428 B
Go
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
|
||
|
}
|