models

package
v0.0.0-...-a7fa96f Latest Latest
Warning

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

Go to latest
Published: May 1, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorMessageType     = "error"
	ChatMessageType      = "chat"
	SubscribeMessageType = "subscribe"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ChatRequest

type ChatRequest struct {
	Type        string `json:"type" validate:"required,oneof=chat subscribe"`
	Data        string `json:"data" validate:"required,max=500"`
	Destination string `json:"destination" validate:"max=50"`
}

type ChatResponse

type ChatResponse struct {
	Type      string `json:"type"`
	Data      string `json:"data"`
	From      string `json:"from"`
	Timestamp string `json:"timestamp"`
}

type ISession

type ISession interface {
	WriteMessage(msg ChatResponse) error
	ReadLoop()
	Close() error
}

type MyClaims

type MyClaims struct {
	UserID   string
	UserName string
}

type Session

type Session struct {
	Id               string
	Conn             net.Conn
	Validator        *validator.Validate
	Log              *zap.SugaredLogger
	Authenticated    bool
	Claims           MyClaims
	OnMessageHandler func(session *Session, msg ChatRequest)
	OnErrorHandler   func(session *Session, err error)
	OnClose          func(session *Session)
}

func (*Session) Close

func (s *Session) Close() error

func (*Session) ReadLoop

func (s *Session) ReadLoop()

func (*Session) WriteMessage

func (s *Session) WriteMessage(msg ChatResponse) error

Jump to

Keyboard shortcuts

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