Documentation ¶
Index ¶
- Variables
- func GetUpgrader() *websocket.Upgrader
- func LockCollections()
- func ReadSocket(connection *Connection, f ...ReadFunc)
- func RemoveCollection(name string)
- func RemoveCollectionIfEmpty(name string)
- func UnlockCollections()
- type Collection
- func (C *Collection) AddConnection(connection *Connection)
- func (C *Collection) All() []*Connection
- func (C *Collection) ConnectionExists(connection *Connection) bool
- func (C *Collection) Count() int
- func (C *Collection) GetConnections() []*Connection
- func (C *Collection) GetName() string
- func (C *Collection) HasRelated(key string, values ...interface{}) []*Connection
- func (C *Collection) HasTag(tag string) []*Connection
- func (C *Collection) HasUUID(uuid string) []*Connection
- func (C *Collection) LockUp()
- func (C Collection) New() *Collection
- func (C *Collection) RemoveConnection(connection *Connection)
- func (C *Collection) RemoveConnectionByUUID(uuid string)
- func (C Collection) Send(messageType int, data []byte, connections ...*Connection)
- func (C Collection) SendCommand(command *JSONRequest, connections ...*Connection)
- func (C Collection) SendData(data []byte, connections ...*Connection)
- func (C Collection) SendText(data string, connections ...*Connection)
- func (C *Collection) String() string
- func (C *Collection) UUIDExists(uuid string) bool
- func (C *Collection) Unlock()
- type CollectionInterface
- type CommandRequest
- type Connection
- func (C *Connection) Close() error
- func (C *Connection) GetCollection() *Collection
- func (C *Connection) GetUUID() string
- func (C Connection) New(socket *websocket.Conn) *Connection
- func (C *Connection) PeerAddress() net.Addr
- func (C *Connection) Ping() error
- func (C *Connection) Pong(v interface{}) error
- func (C *Connection) ReadMessage() (messageType int, p []byte, err error)
- func (C *Connection) SetCollection(collection *Collection)
- func (C *Connection) SetUUID(uuid string)
- func (C *Connection) String() string
- func (C *Connection) SwapTags(from []string, to []string) ([]string, error)
- func (C *Connection) WriteMessage(messageType int, data []byte) error
- type JSONRequest
- type ReadFunc
- type Request
Constants ¶
This section is empty.
Variables ¶
View Source
var WebSocketCollections = make(map[string]*Collection)
Functions ¶
func GetUpgrader ¶
func LockCollections ¶
func LockCollections()
func ReadSocket ¶
func ReadSocket(connection *Connection, f ...ReadFunc)
func RemoveCollection ¶
func RemoveCollection(name string)
func RemoveCollectionIfEmpty ¶
func RemoveCollectionIfEmpty(name string)
func UnlockCollections ¶
func UnlockCollections()
Types ¶
type Collection ¶
type Collection struct { Name string // contains filtered or unexported fields }
func NewCollection ¶
func NewCollection(name string) *Collection
func (*Collection) AddConnection ¶
func (C *Collection) AddConnection(connection *Connection)
func (*Collection) All ¶
func (C *Collection) All() []*Connection
func (*Collection) ConnectionExists ¶
func (C *Collection) ConnectionExists(connection *Connection) bool
func (*Collection) Count ¶
func (C *Collection) Count() int
func (*Collection) GetConnections ¶
func (C *Collection) GetConnections() []*Connection
func (*Collection) GetName ¶
func (C *Collection) GetName() string
func (*Collection) HasRelated ¶
func (C *Collection) HasRelated(key string, values ...interface{}) []*Connection
func (*Collection) HasTag ¶
func (C *Collection) HasTag(tag string) []*Connection
func (*Collection) HasUUID ¶
func (C *Collection) HasUUID(uuid string) []*Connection
func (*Collection) LockUp ¶
func (C *Collection) LockUp()
func (Collection) New ¶
func (C Collection) New() *Collection
func (*Collection) RemoveConnection ¶
func (C *Collection) RemoveConnection(connection *Connection)
func (*Collection) RemoveConnectionByUUID ¶
func (C *Collection) RemoveConnectionByUUID(uuid string)
func (Collection) Send ¶
func (C Collection) Send(messageType int, data []byte, connections ...*Connection)
func (Collection) SendCommand ¶
func (C Collection) SendCommand(command *JSONRequest, connections ...*Connection)
func (Collection) SendData ¶
func (C Collection) SendData(data []byte, connections ...*Connection)
func (Collection) SendText ¶
func (C Collection) SendText(data string, connections ...*Connection)
func (*Collection) String ¶
func (C *Collection) String() string
func (*Collection) UUIDExists ¶
func (C *Collection) UUIDExists(uuid string) bool
func (*Collection) Unlock ¶
func (C *Collection) Unlock()
type CollectionInterface ¶
type CollectionInterface interface { LockUp() Unlock() AddConnection(connection *Connection) RemoveConnection(connection *Connection) RemoveConnectionByUUID(uuid string) UUIDExists(uuid string) bool ConnectionExists(connection *Connection) bool Count() int String() string GetConnections() []*Connection GetName() string All() []*Connection HasTag(tag string) []*Connection HasRelated(key string, values ...interface{}) []*Connection HasUUID(uuid string) []*Connection SendCommand(command *JSONRequest, connections ...*Connection) SendData(data []byte, connections ...*Connection) SendText(data string, connections ...*Connection) Send(messageType int, data []byte, connections ...*Connection) }
type CommandRequest ¶
func (*CommandRequest) GetCommand ¶
func (R *CommandRequest) GetCommand() string
func (*CommandRequest) GetData ¶
func (R *CommandRequest) GetData() interface{}
func (*CommandRequest) GetParams ¶
func (R *CommandRequest) GetParams() interface{}
type Connection ¶
type Connection struct { Related map[string]interface{} Tags []string // contains filtered or unexported fields }
func (*Connection) Close ¶
func (C *Connection) Close() error
Closes the WebSocket and Removes from collection
func (*Connection) GetCollection ¶
func (C *Connection) GetCollection() *Collection
func (*Connection) GetUUID ¶
func (C *Connection) GetUUID() string
func (Connection) New ¶
func (C Connection) New(socket *websocket.Conn) *Connection
func (*Connection) PeerAddress ¶
func (C *Connection) PeerAddress() net.Addr
Returns the remote network address.
func (*Connection) Ping ¶
func (C *Connection) Ping() error
func (*Connection) Pong ¶
func (C *Connection) Pong(v interface{}) error
func (*Connection) ReadMessage ¶
func (C *Connection) ReadMessage() (messageType int, p []byte, err error)
func (*Connection) SetCollection ¶
func (C *Connection) SetCollection(collection *Collection)
func (*Connection) SetUUID ¶
func (C *Connection) SetUUID(uuid string)
func (*Connection) String ¶
func (C *Connection) String() string
func (*Connection) SwapTags ¶
func (C *Connection) SwapTags(from []string, to []string) ([]string, error)
func (*Connection) WriteMessage ¶
func (C *Connection) WriteMessage(messageType int, data []byte) error
type JSONRequest ¶
type JSONRequest struct { Command string Data map[string]interface{} Params map[string]interface{} }
func (*JSONRequest) GetCommand ¶
func (R *JSONRequest) GetCommand() string
func (*JSONRequest) GetData ¶
func (R *JSONRequest) GetData() interface{}
func (*JSONRequest) GetParams ¶
func (R *JSONRequest) GetParams() interface{}
func (JSONRequest) New ¶
func (R JSONRequest) New() *JSONRequest
type ReadFunc ¶
type ReadFunc = func(*Connection, []byte)
Click to show internal directories.
Click to hide internal directories.