transport

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitHub

func InitHub(ctx context.Context, ex exchange.Exchange, logger common.Logger)

Types

type GetConversationMembers

type GetConversationMembers func(appID, conversationId string) ([]string, error) // 获取会话成员

type Hub

type Hub struct {
	// contains filtered or unexported fields
}
var ClientHub *Hub

func (*Hub) Drop

func (h *Hub) Drop(transport *Transport)

Drop 剔除一条链接

func (*Hub) Join

func (h *Hub) Join(appID, Tag string, conn *websocket.Conn)

Join 加入一条链接

func (*Hub) PushToExchange

func (h *Hub) PushToExchange(appID string, msg Message)

PushToExchange 将消费推送到消息交换器

func (*Hub) Run

func (h *Hub) Run(ctx context.Context)

Run 启动

type Message

type Message struct {
	From           string          `json:"from,omitempty"`            //发送者ID
	To             string          `json:"to,omitempty"`              //接收者ID
	Event          exchange.Event  `json:"event,omitempty"`           //事件类型
	Data           exchange.Fields `json:"data,required"`             //消息内容
	MsgID          string          `json:"msg_id,required"`           //消息ID
	SendAt         int64           `json:"send_at,required"`          //发送时间
	ConversationID string          `json:"conversation_id,omitempty"` //会话ID
}

type Transport

type Transport struct {
	AppID string // 应用ID
	Tag   string // 连接标签
	Key   string // 连接标识  = makeTransportKey(AppID:Tag)
	// contains filtered or unexported fields
}

func NewTransport

func NewTransport(appID, tag string, conn *websocket.Conn, hub *Hub) *Transport

NewTransport 创建一个新的连接

func (*Transport) Send

func (trans *Transport) Send(message Message)

Send 发送消息

func (*Transport) Start

func (trans *Transport) Start()

Jump to

Keyboard shortcuts

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