Documentation ¶
Index ¶
- func UpgradeConnection(w http.ResponseWriter, r *http.Request) (*websocket.Conn, error)
- type Client
- type MessageMetadata
- type MessageTransport
- type Pool
- func (pool *Pool) AddClientToPool(client *Client)
- func (pool *Pool) BroadcastMessage(message *MessageTransport, sendToAllClients bool) error
- func (pool *Pool) BroadcastServerMessage(message string) error
- func (pool *Pool) BroadcastUsersQty() error
- func (pool *Pool) DeleteClientFromPool(client *Client) error
- func (pool *Pool) LogInClient(client *Client) error
- func (pool *Pool) LogOutClient(client *Client) error
- func (pool *Pool) NewClient(user *users.User, conn *websocket.Conn) *Client
- func (pool *Pool) SendHistoryToClient(client *Client) error
- func (pool *Pool) SendMessageToClient(message *MessageTransport, client *Client) error
- func (pool *Pool) SendUsersQtyToClient(client *Client) error
- func (pool *Pool) ServeWs(w http.ResponseWriter, r *http.Request)
- func (pool *Pool) Start()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func UpgradeConnection ¶
Types ¶
type Client ¶
func (*Client) IsAuthorized ¶
IsAuthorized identify if the client provided its name before.
type MessageMetadata ¶
type MessageMetadata struct {
MessageType messages.MessageType `json:"type"`
}
type MessageTransport ¶
type MessageTransport struct { MessageType messages.MessageType `json:"type"` Payload interface{} `json:"payload"` }
func NewMessageTransport ¶
func NewMessageTransport(messageType messages.MessageType, payloadObject interface{}) *MessageTransport
NewMessageTransport generates new transport for the message.
func (*MessageTransport) MarshalJSON ¶
func (m *MessageTransport) MarshalJSON() ([]byte, error)
func (*MessageTransport) UnmarshalJSON ¶
func (m *MessageTransport) UnmarshalJSON(bytes []byte) error
type Pool ¶
type Pool struct { History *history.History Clients map[*Client]bool Register chan *Client Unregister chan *Client LogIn chan *Client LogOut chan *Client Broadcast chan *MessageTransport }
func (*Pool) AddClientToPool ¶
func (*Pool) BroadcastMessage ¶
func (pool *Pool) BroadcastMessage(message *MessageTransport, sendToAllClients bool) error
func (*Pool) BroadcastServerMessage ¶
func (*Pool) BroadcastUsersQty ¶
func (*Pool) DeleteClientFromPool ¶
func (*Pool) LogInClient ¶
LogInClient sends JWT to the client
func (*Pool) LogOutClient ¶
func (*Pool) SendHistoryToClient ¶
func (*Pool) SendMessageToClient ¶
func (pool *Pool) SendMessageToClient(message *MessageTransport, client *Client) error
func (*Pool) SendUsersQtyToClient ¶
Click to show internal directories.
Click to hide internal directories.