chatting

package
v0.0.0-...-cea2a50 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRoomHandler

func NewRoomHandler() *roomHandler

Types

type ChatMessage

type ChatMessage struct {
	CommandId CommandID `json:"command"`
	User      *string   `json:"username"`
	Args      []string  `json:"args"`
}

type Client

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

func (*Client) ReadCommands

func (c *Client) ReadCommands()

func (*Client) WriteMsg

func (c *Client) WriteMsg(message string, userName ...string)

type Command

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

Command used by client to manage interaction with chat

type CommandID

type CommandID string

CommandID helper type for commands

const (
	CmdMsg   CommandID = "msg"
	CmdJoin  CommandID = "join"
	CmdPing  CommandID = "ping"
	CmdQuit  CommandID = "quit"
	CmdRooms CommandID = "rooms"
	CmdUsers CommandID = "users"
)

func ConvertToCommandID

func ConvertToCommandID(input string) (CommandID, error)

type Repository

type Repository interface {
	WriteMessage(c *Client, r *Room, msg string) error
	ExcludeFromRoom(name string, c *Client) error
	AddUserToRoom(name string, c *Client) error
	RoomHasUser(name string, c *Client) (bool, int)
}

type Room

type Room struct {
	Clients map[*Client]struct{}
	Name    string
}

Room is the place for clients

type Service

type Service interface {
	Run()
	NewClient(conn *websocket.Conn, nick string)
	Repository
}

func NewService

func NewService(rep Repository) Service

Jump to

Keyboard shortcuts

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