ws

package
v0.0.0-...-2eb9458 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2021 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ChatMsgTypeSystem = "system"
	ChatMsgTypeText   = "text"
	ChatMsgTypeImage  = "image"
	ChatMsgTypeCmd    = "cmd"
)

Variables

This section is empty.

Functions

func AgentChatHandler

func AgentChatHandler(r *ghttp.Request)

func VisitorChatHandler

func VisitorChatHandler(r *ghttp.Request)

Types

type Bucket

type Bucket struct {
	ChannelSize int
	// contains filtered or unexported fields
}

func (*Bucket) Del

func (b *Bucket) Del(uid string)

func (*Bucket) Set

func (b *Bucket) Set(uid string, ch *Channel)

type Channel

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

func (*Channel) WriteMessage

func (ch *Channel) WriteMessage(msg *ChatMsg) error

func (*Channel) WriteSystemMessage

func (ch *Channel) WriteSystemMessage(aid, vid, text string) error

func (*Channel) WriteSystemMessagef

func (ch *Channel) WriteSystemMessagef(aid, vid, text string, format string, v ...interface{}) error

func (*Channel) WriteTextMessage

func (ch *Channel) WriteTextMessage(aid, vid, text string) error

func (*Channel) WriteTextMessagef

func (ch *Channel) WriteTextMessagef(aid, vid, format string, v ...interface{}) error

type ChatMsg

type ChatMsg struct {
	AgentID   string                 `json:"agentID"`
	VisitorID string                 `json:"visitorID"`
	Type      string                 `json:"type"`
	Content   map[string]interface{} `json:"content" v:"required"`
	CreatedAt int64                  `json:"createdAt"`
}

func NewChatMsg

func NewChatMsg(aid, vid, msgType string, content map[string]interface{}) *ChatMsg

type Conversation

type Conversation struct {
	VisitorID string                 `json:"id"`
	Nickname  string                 `json:"nickname"`
	Content   map[string]interface{} `json:"content"`
	ActiveAt  time.Time              `json:"activeAt"`
}

func GetRealtimeConversations

func GetRealtimeConversations(ctx context.Context) ([]*Conversation, error)

GetRealtimeConversations 获取当前所有对话

type Server

type Server struct {
	Buckets []*Bucket

	WriteWait  time.Duration
	PongWait   time.Duration
	PingPeriod time.Duration
	MaxMsgSize int64
	BufSize    int
	// contains filtered or unexported fields
}

func AgentChatSrv

func AgentChatSrv() *Server

AgentChatSrv .

func NewServer

func NewServer() *Server

NewServer .

func VisitorChatSrv

func VisitorChatSrv() *Server

VisitorChatSrv .

func (*Server) Bucket

func (srv *Server) Bucket(uid string) *Bucket

func (*Server) GetChannelByUID

func (srv *Server) GetChannelByUID(uid string) *Channel

Jump to

Keyboard shortcuts

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