messages

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2023 License: MIT Imports: 6 Imported by: 6

Documentation

Index

Constants

View Source
const (
	ActionHello               Action = "hello"
	ActionHeartbeat                  = "heartbeat"
	ActionNotifyUnknownAction        = "notify.unknown.action"

	ActionChatMessage       = "message.chat"
	ActionChatMessageResend = "message.chat.resend"
	ActionGroupMessage      = "message.group"

	ActionAuthenticate          = "authenticate"
	ActionNotifyError           = "notify.error"
	ActionNotifySuccess         = "notify.success"
	ActionNotifyKickOut         = "notify.kickout"
	ActionNotifyForbidden       = "notify.forbidden"
	ActionNotifyUnauthenticated = "notify.unauthenticated"

	ActionInternalOnline  = "internal.online"
	ActionInternalOffline = "internal.offline"
)

Variables

View Source
var DefaultCodec = JsonCodec
View Source
var JsonCodec = jsonCodec{}
View Source
var ProtoBuffCodec = protobufCodec{}

Functions

func IsDecodeError added in v1.3.1

func IsDecodeError(err error) bool

Types

type AckGroupMessage

type AckGroupMessage struct {
	CliMid string `json:"cliMid,omitempty"`
	Gid    int64  `json:"gid,omitempty"`
	Mid    int64  `json:"mid,omitempty"`
	Seq    int64  `json:"seq,omitempty"`
}

AckGroupMessage 发送群消息服务器回执

type AckMessage

type AckMessage struct {
	CliMid string `json:"cliMid,omitempty"`
	/// message id to tall the client
	Mid int64 `json:"mid,omitempty"`
	Seq int64 `json:"seq,omitempty"`
}

AckMessage 服务端通知发送者的服务端收到消息

type AckNotify

type AckNotify struct {
	Mid int64 `json:"mid,omitempty"`
}

AckNotify 服务端下发给发送者的消息送达通知

type AckRequest

type AckRequest struct {
	Seq  int64  `json:"seq,omitempty"`
	Mid  int64  `json:"mid,omitempty"`
	From string `json:"from,omitempty"`
}

AckRequest 接收者回复给服务端确认收到消息

type Action

type Action string

Action is the type of action that is being performed.

func (Action) IsInternal added in v1.2.5

func (a Action) IsInternal() bool

type ChatMessage

type ChatMessage struct {
	/// client message id to identity unique a message.
	/// for identity a message
	/// and wait for the server ack receipt and return `mid` for it.
	CliMid string `json:"cliMid,omitempty"`
	/// server message id in the database.
	// when a client sends a message for the first time or  client retry to send a message that
	// the server does not ack, the 'Mid' is empty.
	/// if this field is not empty that this message is server acked, need not store to database again.
	Mid int64 `json:"mid,omitempty"`
	/// message sequence for a chat, use to check message whether the message lost.
	Seq int64 `json:"seq,omitempty"`
	/// message sender
	From string `json:"from,omitempty"`
	/// message send to
	To string `json:"to,omitempty"`
	/// message type
	Type int32 `json:"type,omitempty"`
	/// message content
	Content string `json:"content,omitempty"`
	/// message send time, server store message time.
	SendAt int64 `json:"sendAt,omitempty"`
}

ChatMessage chat message in single/group chat

type ClientCustom

type ClientCustom struct {
	Type    string      `json:"type,omitempty"`
	Content interface{} `json:"content,omitempty"`
}

ClientCustom client custom message, server does not store to database.

type Codec

type Codec interface {
	Decode(data []byte, i interface{}) error
	Encode(i interface{}) ([]byte, error)
}

type Data

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

Data used to wrap message data. Server received a message, the data type is []byte, it's waiting for deserialize to specified struct. When server push a message to client, the data type is specific struct.

func NewData

func NewData(d interface{}) *Data

func (*Data) Deserialize

func (d *Data) Deserialize(i interface{}) error

func (*Data) GetData added in v1.4.7

func (d *Data) GetData() interface{}

func (*Data) MarshalJSON

func (d *Data) MarshalJSON() ([]byte, error)

func (*Data) String added in v1.2.1

func (d *Data) String() string

func (*Data) UnmarshalJSON

func (d *Data) UnmarshalJSON(bytes []byte) error

type GlideMessage

type GlideMessage struct {
	Ver    int64  `json:"ver,omitempty"`
	Seq    int64  `json:"seq,omitempty"`
	Action string `json:"action"`
	From   string `json:"from,omitempty"`
	To     string `json:"to,omitempty"`
	Data   *Data  `json:"data,omitempty"`
	Msg    string `json:"msg,omitempty"`

	Ticket string `json:"ticket,omitempty"`
	Sign   string `json:"sign,omitempty"`

	Extra map[string]string `json:"extra,omitempty"`
}

GlideMessage common data of all message

func NewEmptyMessage

func NewEmptyMessage() *GlideMessage

func NewMessage

func NewMessage(seq int64, action Action, data interface{}) *GlideMessage

func (*GlideMessage) GetAction

func (g *GlideMessage) GetAction() Action

func (*GlideMessage) GetSeq

func (g *GlideMessage) GetSeq() int64

func (*GlideMessage) SetSeq

func (g *GlideMessage) SetSeq(seq int64)

func (*GlideMessage) String added in v1.2.1

func (g *GlideMessage) String() string

type GlideProtocol

type GlideProtocol struct {
}

type Hello added in v1.2.2

type Hello struct {
	ClientVersion string `json:"client_version,omitempty"`
	ClientName    string `json:"client_name,omitempty"`
	ClientType    string `json:"client_type,omitempty"`
}

type KickOutNotify added in v1.5.0

type KickOutNotify struct {
	DeviceId   string `json:"device_id,omitempty"`
	DeviceName string `json:"device_name,omitempty"`
}

type ServerHello added in v1.3.3

type ServerHello struct {
	ServerVersion     string   `json:"server_version,omitempty"`
	TempID            string   `json:"temp_id,omitempty"`
	HeartbeatInterval int      `json:"heartbeat_interval,omitempty"`
	Protocols         []string `json:"protocols,omitempty"`
}

Jump to

Keyboard shortcuts

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