chatsession

package
v0.0.0-...-fee56ab Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chatroom

type Chatroom struct {
	Clients map[string]*UserClient
	Client  chan *UserClient
	Relay   chan *UserMessage
	Remove  chan *UserClient
}

func CreateChatroom

func CreateChatroom() *Chatroom

func (*Chatroom) ReceiveAndNotify

func (cr *Chatroom) ReceiveAndNotify()

func (*Chatroom) RegisterClient

func (cr *Chatroom) RegisterClient()

func (*Chatroom) RemoveClient

func (cr *Chatroom) RemoveClient()

func (*Chatroom) SendUserList

func (cr *Chatroom) SendUserList()

type ClientList

type ClientList struct {
	Clients []string `json:"user_list"`
}

type UserClient

type UserClient struct {
	Username   string
	Chatroom   *Chatroom
	Connection *websocket.Conn
	Message    chan *UserMessage
	ClientList chan *ClientList
}

func CreateUserClient

func CreateUserClient(username string, cr *Chatroom, conn *websocket.Conn) *UserClient

func (*UserClient) ReadMessage

func (uc *UserClient) ReadMessage()

func (*UserClient) WriteMessage

func (uc *UserClient) WriteMessage()

type UserMessage

type UserMessage struct {
	Username string `json:"username"`
	Message  string `json:"message"`
}

Jump to

Keyboard shortcuts

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