package websocket import ( "io" "net/http" "sync" "time" "github.com/gorilla/websocket" ) type Client interface { ID() string RemoteAddr() string UserAgent() string SetWriteDeadline(t time.Time) error SetReadDeadline(t time.Time) error SetReadLimit(limit int64) SetPongHandler(h func(appData string) error) SetPingHandler(h func(appData string) error) WriteControl(messageType int, data []byte, deadline time.Time) error WriteMessage(messageType int, data []byte) error ReadMessage() (messageType int, p []byte, err error) NextWriter(messageType int) (io.WriteCloser, error) IsClosed() bool Close() error } type client struct { id string server *server httpRequest *http.Request conn *websocket.Conn writeMTX sync.Mutex } var _ Client = &client{} func newClient(s *server, r *http.Request, conn *websocket.Conn, clientID string) Client { c := &client{ id: clientID, server: s, httpRequest: r, conn: conn, } return c } func (c *client) ID() string { return c.id } func (c *client) RemoteAddr() string { return c.httpRequest.RemoteAddr } func (c *client) UserAgent() string { return c.httpRequest.UserAgent() } func (c *client) SetWriteDeadline(t time.Time) error { return c.conn.SetWriteDeadline(t) } func (c *client) ID() string { return c.id } func (c *client) ID() string { return c.id } func (c *client) ID() string { return c.id } func (c *client) ID() string { return c.id } func (c *client) ID() string { return c.id } func (c *client) ID() string { return c.id } func (c *client) ID() string { return c.id } func (c *client) ID() string { return c.id } func (c *client) ID() string { return c.id } func (c *client) ID() string { return c.id } func (c *client) ID() string { return c.id }