Documentation ¶
Index ¶
- Constants
- Variables
- func Decode(raw string) (method, topic string, metas []string)
- func DecodeData(data ...string) (method, topic string, metas []string)
- func Encode(method, topic string, metas ...string) []byte
- type Agent
- type AuthMethod
- type Client
- type Server
- func (s *Server) Boardcast(topic string, metas ...string)
- func (s *Server) GC()
- func (s *Server) GetUpdated(conn *websocket.Conn, ch chan<- TopicEvent)
- func (s *Server) Join(conn *websocket.Conn)
- func (s *Server) Leave(conn *websocket.Conn)
- func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (s *Server) Sub(conn *websocket.Conn, topic string)
- func (s *Server) Unsub(conn *websocket.Conn, topic string)
- type ServerFunc
- type Topic
- type TopicEvent
Constants ¶
View Source
const ( // Time allowed to write the file to the client. WriteWait = 10 * time.Second // Time allowed to read the next pong message from the client. PongWait = 60 * time.Second // Send pings to client with this period. Must be less than pongWait. PingPeriod = (PongWait * 9) / 10 )
View Source
const DefaultMessageCache = 1
View Source
const UnitSeparator = "\x1F"
Variables ¶
View Source
var DefaultDialer = websocket.DefaultDialer
View Source
var DefaultReadWait = PongWait
View Source
var DefaultUpgrader = websocket.Upgrader{ ReadBufferSize: 128, WriteBufferSize: 128, CheckOrigin: func(r *http.Request) bool { return true }, }
View Source
var DefaultWriteWait = WriteWait
Functions ¶
func DecodeData ¶
Types ¶
type AuthMethod ¶
type AuthMethod int
const ( AuthMethod_Auth AuthMethod = iota AuthMethod_Sub AuthMethod_Boardcast )
func (AuthMethod) String ¶
func (am AuthMethod) String() string
type Client ¶
type Client struct { URL string Token string // for auth Dialer *websocket.Dialer OnTopic func(topic string, metas ...string) AfterOpen func(conn *websocket.Conn) OnError func(error) ReadWait time.Duration WriteWait time.Duration S chan string // subscribe U chan string // unsubscrbe B chan TopicEvent // boardcast }
type Server ¶
type Server struct { C chan ServerFunc // never closed Agents map[*websocket.Conn]*Agent InitMetas map[string][]string // map[topic]metas // status MessageSent int // readonly Upgrader websocket.Upgrader MessageCache int Auth func(token string, m AuthMethod, topic string) bool }
func (*Server) GetUpdated ¶
func (s *Server) GetUpdated(conn *websocket.Conn, ch chan<- TopicEvent)
type ServerFunc ¶
type ServerFunc func(*Server)
type TopicEvent ¶
Click to show internal directories.
Click to hide internal directories.