Documentation
¶
Index ¶
- Variables
- func NewSocket(handler func(*Socket), upgraderConfig ...*Upgrader) func(http.ResponseWriter, *http.Request)
- type H
- type Message
- type Socket
- func (ctx *Socket) AddRoom(room string)
- func (ctx *Socket) CicleEvents()
- func (ctx *Socket) CloseSignal() error
- func (ctx *Socket) Event(eventName string, handler func(interface{}))
- func (ctx *Socket) ForceClose()
- func (ctx *Socket) Read() ([]byte, error)
- func (ctx *Socket) ReadMessage() (*Message, error)
- func (ctx *Socket) Send(event string, d interface{}) error
- func (ctx *Socket) WCFG(mode string, data interface{}) error
- func (ctx *Socket) WLOG(data interface{}) error
- func (ctx *Socket) WLOGISTRUE(boolVar bool, data interface{}) bool
- type Upgrader
- func (ctx *Upgrader) ChangeID(user *Socket, newID string) (change bool)
- func (ctx *Upgrader) ChangeIDReconection(user *Socket, newID string) (change bool)
- func (ctx *Upgrader) GetUser(ID string) (err error, user *Socket)
- func (ctx *Upgrader) Send(event string, data interface{}, room string)
- func (ctx *Upgrader) SendArray(room string, message []Message) []error
- func (ctx *Upgrader) SendMasive(event string, data interface{}, notSend ...*Socket)
- func (ctx *Upgrader) Users() []*Socket
- func (ctx *Upgrader) UsersInRoom(room string) []*Socket
- func (ctx *Upgrader) WCFG(mode string, data interface{}, room string)
- func (ctx *Upgrader) WLOG(data interface{}, room string)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ModeClient Modes cfg: for server send to client ModeClient = struct { Log string SetConfiguration string CloseGusk string }{ Log: "server->client:log", SetConfiguration: "server->client:set-configuration", CloseGusk: "server->client:close-gusk", } // ModeServer Modes cfg: for client send to server ModeServer = struct { CloseGusk string GetConfiguration string SetConfigurationReconection string }{ CloseGusk: "client->server:close-gusk", GetConfiguration: "client->server:get-configuration", SetConfigurationReconection: "client->server:set-configuration-reconection", } )
Functions ¶
Types ¶
type Socket ¶
type Socket struct { WS *websocket.Conn `json:"-"` // ID user conection ID string HTTP struct { Request *http.Request } `json:"-"` // Is Socket Upgrader *Upgrader `json:"-"` Connect bool `json:"-"` Finish chan error `json:"-"` SocketData *socketData `json:"-"` Reconection bool `json:"-"` OnClose func() `json:"-"` }
Socket model for conection
func (*Socket) CloseSignal ¶
CloseSignal websocket connection
func (*Socket) ReadMessage ¶
ReadMessage read message and parse
func (*Socket) WLOGISTRUE ¶
WLOGISTRUE read message and send if true
type Upgrader ¶
Upgrader model for message
func (*Upgrader) ChangeIDReconection ¶
ChangeID to user
func (*Upgrader) SendMasive ¶
SendMasive write json to all users
func (*Upgrader) UsersInRoom ¶
UsersInRoom get users in room
Click to show internal directories.
Click to hide internal directories.