Documentation ¶
Index ¶
Constants ¶
View Source
const ( // AuthMessage message AuthMessage MessageType = "authMessage" // AuthFail message AuthFail MessageType = "authFail" // UserJoined message UserJoined MessageType = "userJoined" // PrivateMessage message PrivateMessage MessageType = "privateMessage" //Broadcast message Broadcast MessageType = "broadcast" //UsersStatus message UsersStatus MessageType = "usersStatus" // WriteWait Time allowed to write a message to the peer. WriteWait = 10 * time.Second // PongWait Time allowed to read the next pong message from the peer. PongWait = 60 * time.Second // PongPeriod should less than PongWait PingPeriod = (PongWait * 9) / 10 // Maximum message size allowed from peer. MaxMessageSize = 1024 )
View Source
const ( // UpdateStatusWait to update users status UpdateStatusWait = 2 * time.Second )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { *websocket.Conn ID string Username string MsgChan chan []byte Manager *Manager Room map[string]bool IsOnline bool sync.RWMutex }
Client model
type Manager ¶
type Manager struct { AuthKey string Clients Clients JoinedClient chan *Client ExitedClient chan *Client AuthSuccess chan *Client IncomingMessage chan *Message Upgrader websocket.Upgrader JwtService jwt.JwtService sync.RWMutex // contains filtered or unexported fields }
Manager will manage client and chat
func NewManager ¶
func NewManager(authKey string, jwtService jwt.JwtService) *Manager
NewManager function
type Message ¶
type Message struct { MessageType MessageType `json:"messageType,omitempty"` AuthKey string `json:"authKey,omitempty"` Token string `json:"token,omitempty"` Username string `json:"username,omitempty"` From string `json:"from,omitempty"` To string `json:"to,omitempty"` Content string `json:"content,omitempty"` Date time.Time `json:"date,omitempty"` OnlineUsers []*OnlineUser `json:"onlineUsers,omitempty"` }
Message structure
type OnlineUser ¶
OnlineUser represent online user
Click to show internal directories.
Click to hide internal directories.