chat_server

package module
v0.0.0-...-9740337 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2020 License: MIT Imports: 9 Imported by: 0

README

chat-server

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ServeWs

func ServeWs(hub *Hub, w http.ResponseWriter, r *http.Request, c *Controller)

serveWs handles websocket requests from the peer.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a middleman between the websocket connection and the hub.

type Command

type Command struct {
	Command string                   `json:"command"`
	Data    map[string](interface{}) `json:"data"`
}

type Controller

type Controller struct {
	// contains filtered or unexported fields
}

func NewController

func NewController(rdb *redis.Client) *Controller

func (*Controller) HandleIncomingCommand

func (c *Controller) HandleIncomingCommand(command Command, client *Client)

type Hub

type Hub struct {
	// contains filtered or unexported fields
}

Hub maintains the set of active clients and broadcasts messages to the clients.

func NewHub

func NewHub() *Hub

func (*Hub) Run

func (h *Hub) Run()

type Message

type Message struct {
	Text string `json:"text"`
}

func RedisMessagesUnmarshaller

func RedisMessagesUnmarshaller(messages []string) []Message

type MessageListReply

type MessageListReply struct {
	Command  string    `json:"command"`
	Messages []Message `json:"messages"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL