chat

package
v0.0.0-...-9ce0fb8 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chat

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

Chat represents a chat session

func New

func New(conf Config, logs *logger.Logger) (*Chat, error)

New creates a new Chat instance

func (*Chat) Broadcast

func (chat *Chat) Broadcast(message *Message)

Broadcast a message to all clients

func (*Chat) GetHandler

func (chat *Chat) GetHandler() http.HandlerFunc

GetHandler creates a new http request websocket upgrader

type Client

type Client string

Client represents a chat client

func NewClient

func NewClient() Client

NewClient creates a new Client

type Config

type Config interface {
	GetHost() string
	GetPort() string
	GetClientHost() string
	GetClientPort() string
}

Config represents a chat config

type Message

type Message struct {
	Author   Client    `json:"author"`
	Message  string    `json:"message"`
	IssuedAt time.Time `json:"issuedAt"`
}

Message represents a chat client

func MakeMessage

func MakeMessage(from string) *Message

MakeMessage creates a new Client

func (*Message) MustParseString

func (m *Message) MustParseString() string

MustParseString converts a Message type into JSON string. If an error occurs it panics

func (*Message) String

func (m *Message) String() (string, error)

String converts a Message type into a JSON string

Jump to

Keyboard shortcuts

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