gochat

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

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

Go to latest
Published: Feb 26, 2024 License: GPL-3.0 Imports: 15 Imported by: 0

README

go-chat

Documentation

Index

Constants

View Source
const (
	MessageType_System = "system"
	MessageType_Msg    = "msg"
)

Variables

This section is empty.

Functions

func RunMigrations

func RunMigrations(db *sql.DB) error

Types

type Broker

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

func NewBroker

func NewBroker(repo *Repo) *Broker

func (*Broker) NewChannel

func (b *Broker) NewChannel(w http.ResponseWriter, r *http.Request)

func (*Broker) Publish

func (b *Broker) Publish(m *Message, store bool)

func (*Broker) Subscribe

func (b *Broker) Subscribe(w http.ResponseWriter, r *http.Request, h Handler)

type Channel

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

func (*Channel) Publish

func (c *Channel) Publish(m *Message, store bool)

type ChannelEntry

type ChannelEntry struct {
	Id   string `json:"id"`
	Name string `json:"name"`
}

type FileEntry

type FileEntry struct {
	Filename string `json:"filename"`
	URL      string `json:"url"`
}

type FileUpload

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

func NewFileUpload

func NewFileUpload(broker *Broker) *FileUpload

func (*FileUpload) Upload

func (f *FileUpload) Upload(channel string, msg, user string, file multipart.File, filename string) error

type Handler

type Handler interface {
	Subscribe(w http.ResponseWriter, r *http.Request, b *Broker)
}

type LoginReq

type LoginReq struct {
}

type Message

type Message struct {
	Type      string     `json:"type"`
	Channel   string     `json:"channel"`
	User      string     `json:"user"`
	Content   string     `json:"content"`
	Image     string     `json:"image"`
	File      *FileEntry `json:"file"`
	Timestamp int64      `json:"timestamp"`
}

type Repo

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

func NewRepo

func NewRepo(db *sql.DB) *Repo

func (*Repo) GetChannel

func (r *Repo) GetChannel(id string) (string, error)

func (*Repo) GetChannelByName

func (r *Repo) GetChannelByName(name string) (string, error)

func (*Repo) GetChannels

func (r *Repo) GetChannels() ([]*ChannelEntry, error)

func (*Repo) GetMessages

func (r *Repo) GetMessages(channel string) ([][]byte, error)

func (*Repo) NewChannel

func (r *Repo) NewChannel(name string) (string, error)

func (*Repo) NewUser

func (r *Repo) NewUser(username, password string) (string, error)

func (*Repo) SaveMessage

func (r *Repo) SaveMessage(channel, user string, ts int64, message []byte) (string, error)

type SSE

type SSE struct {
}

func (*SSE) Subscribe

func (sse *SSE) Subscribe(w http.ResponseWriter, r *http.Request, b *Broker)

type WS

type WS struct {
}

func (*WS) Subscribe

func (ws *WS) Subscribe(w http.ResponseWriter, r *http.Request, b *Broker)

Directories

Path Synopsis
examples
ws

Jump to

Keyboard shortcuts

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