wide/util/websocket.go

27 lines
510 B
Go
Raw Normal View History

2014-09-16 11:06:52 +04:00
package util
import (
"net/http"
"time"
"github.com/gorilla/websocket"
)
2014-10-29 13:15:18 +03:00
// WebSocket channel.
2014-09-16 11:06:52 +04:00
type WSChannel struct {
2014-10-29 13:15:18 +03:00
Sid string // wide session id
Conn *websocket.Conn // websocket connection
Request *http.Request // HTTP request related
Time time.Time // the latest use time
2014-09-16 11:06:52 +04:00
}
2014-09-20 06:39:29 +04:00
2014-10-29 13:15:18 +03:00
// Close closed the channel.
2014-09-20 06:39:29 +04:00
func (c *WSChannel) Close() {
c.Conn.Close()
}
2014-10-28 19:04:46 +03:00
2014-10-29 13:15:18 +03:00
// Refresh refreshes the channel by updating its use time.
2014-10-28 19:04:46 +03:00
func (c *WSChannel) Refresh() {
c.Time = time.Now()
}