chat

package
v0.0.0-...-4f4bebd Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2022 License: GPL-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TalkAction  = "talk"
	JoinAction  = "join"
	LeaveAction = "leave"
	ErrorAction = "error"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Chat

type Chat struct {
	sync.Mutex
	Rooms map[string]*Room
}

func NewChat

func NewChat() *Chat

type Client

type Client struct {
	sync.Mutex
	RoomStreams map[string]*MsgStream
	// contains filtered or unexported fields
}

func NewClient

func NewClient(w *websocket.Conn) *Client

func (*Client) HasJoined

func (cl *Client) HasJoined(room string) bool

func (*Client) SendJSON

func (cl *Client) SendJSON(m *Message) error

type Message

type Message struct {
	Action     string
	Room       string
	Username   string
	Content    string
	HTTPstatus int
}

type MsgStream

type MsgStream struct {
	SentMsgs    chan Message
	DoneSending chan bool
}

func NewMsgStream

func NewMsgStream() *MsgStream

type Room

type Room struct {
	Name string `json:"name"`

	sync.Mutex
	// contains filtered or unexported fields
}

func NewRoom

func NewRoom(name string) *Room

func (*Room) ListenToStream

func (room *Room) ListenToStream(s *MsgStream, c *Client)

func (*Room) MarshalJSON

func (r *Room) MarshalJSON() ([]byte, error)

func (*Room) SendMsgs

func (room *Room) SendMsgs()

Jump to

Keyboard shortcuts

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