wsbus

package
v0.0.0-...-99b6fc9 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ClientMap = make(map[string]*WsClient)

Functions

func ReceiveMessage

func ReceiveMessage(ctx context.Context, conn *websocket.Conn)

func SendGroupMessage

func SendGroupMessage(ctx context.Context, sourceId, targetId uint64, message string) error

func SendUserMessage

func SendUserMessage(ctx *ctx.Ctx, sourceId, targetId uint64, message string, datetime time.Time) error

SendUserMessage 发送一对一的消息,先把消息保存到数据库,然后直接通过websocket发送。

如果消息发送失败,也不返回error,保证对方在离线状态下依然可用

msg_time: 如果消息时间是今天,那么不发送日期,如果消息时间不是今天,那么包含日期

Types

type WsClient

type WsClient struct {
	Conn    *websocket.Conn
	MsgChan chan *WsMessage
}

type WsMessage

type WsMessage struct {
	Message  string
	SourceId uint64
	TargetId uint64
}

Jump to

Keyboard shortcuts

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