Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var RoomPool = make([]*Room, 0)
Room Pool containing all rooms currently active
Functions ¶
func GetAllClients ¶
func GetAllClients() int
GetAllClients returns the number of all connected clients
func ListRooms ¶
ListRooms return the number of registered rooms and a slice of strings with all room names in pool
func PoolBroadcast ¶
func PoolBroadcast(m Message)
PoolBroadcast send a message to all clients of the Pool
func RemoveClient ¶
func RemoveClient(c *Client)
RemoveClient removes a client from a room if the client is the only client in the room the room is also removed from the RoomPool
Types ¶
type Client ¶
Client represents an entity connected using a websocket Connection the websocket connection
func (Client) SendMessage ¶
SendMessage sends a message to a connected websocket client
type Message ¶
Message type that will be transmitted over the wire
func NewMessage ¶
NewMessage instantiate a new message to be transmitted to websoket client(s)
type Room ¶
A Room containing a Pool of WebSocket clients each time a websocket client connects, it is added to the ClientPool so we can reference at a later time
func FindRoom ¶
FindRoom finds a room in the RoomPool and returns its index and value. If the room does not exist in pool returns -1 If the RoomPool is empty returns -1
func (*Room) ClientCount ¶
ClientCount returns the number of domain's connected clients
func (*Room) DeleteClient ¶
DeleteClient removes a client from the pool
func (*Room) FindClient ¶
FindClient finds a client in the ClientPool and returns its index and value. If the room does not exists in pool returns -1 If the ClientPool is empty returns -1
func (*Room) ListClients ¶
ListClients returns a slice with IDs of all connected clients
func (*Room) RoomBroadcast ¶
RoomBroadcast send a Message to all domain's connected clients
type User ¶
type User struct { Id int Username string `orm:"unique"` Password string Email string `orm:"unique"` EmailConfirmed bool ConfirmationCode string // used during registration confirmation TODO move to sepparate table and tight up security Created time.Time `orm:"auto_now_add;type(datetime)"` LastLogin time.Time `orm:"type(datetime)"` // use this to set different user types, such as Admin, Staff, User, etc // for more complex situtations a Roles and a Roles_Permissions models could be more of help Role string Active bool // use to lock down the account }
func AuthenticateUser ¶
Authenticate authenticates a User by his username or email and his password Uppon successful authentication returns true, the User object and an empty string When unsuccessful, returns false, empty User object and a string with the error message
func GetUserByEmail ¶
GetUserByUsername searches the database for a user object with the given email
func GetUserByUsername ¶
GetUserByUsername searches the database for a user object with the given username