chat

package
v0.3.7 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: LGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KChatCreateGroup = Event(iota) //创建群
	KChatJoinGroup                 //进群
	KChatLeaveGroup                //退群
	KChatRemoveGroup               //解散群
	KChatMessage                   //发消息
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Chat

type Chat interface {
	SaveChat(msg *Message) (int64, error)
}

type Event

type Event int32

type Group

type Group interface {
	Chat
	GetGroupKey(appId string, plat int32, groupId int64) string
	GetGroupVersion(groupId int64, key string) int64
	UpdateGroupVersion(groupId int64, key string, version int64) error
	// InGroups 加过哪些群组
	InGroups(userId MemberId) ([]GroupUser, error)
	JoinGroup(groupId int64, key string, member *Member) error
	LeaveGroup(groupId int64, key string, memberId MemberId) error
	RemoveGroup(groupId int64, key string) error
	GroupMemberCount(groupId int64, key string) (int64, error)
	GetGroupMember(groupId int64, key string) ([]*Member, error)
}

type GroupModel

type GroupModel struct {
	GroupId int64    `json:"id"`
	Member  []Member `json:"members,omitempty"`
}

type GroupUser

type GroupUser struct {
	ID      int32 `json:"id"`
	GroupID int32 `json:"groupId"`
	UserID  int32 `json:"userId"`
}

type Member

type Member struct {
	UserId MemberId `json:"id"`
	Name   string   `json:"name,omitempty"`
}

type MemberId

type MemberId uint64

func (MemberId) Int

func (m MemberId) Int() uint64

func (MemberId) Int32

func (m MemberId) Int32() int32

func (MemberId) String

func (m MemberId) String() string

type Message

type Message struct {
	// 消息的来源ID(如果是私聊,则是接收用户id,如果是群聊,则是群组id)
	Id       int64    `json:"id"`
	FromId   MemberId `json:"fromid"`   // 消息的发送者id
	ToId     MemberId `json:"toid"`     // 接收者id
	Content  string   `json:"content"`  // 消息
	Type     string   `json:"type"`     // "group", "friend",聊天类型
	Avatar   string   `json:"avatar"`   //消息来源用户头像
	UserName string   `json:"username"` //消息来源用户名
	Mine     bool     `json:"mine"`     //是否我发送的消息,如果为true,则会显示在右方
}

func (*Message) HasValid

func (chat *Message) HasValid() error

func (*Message) IsFriend

func (chat *Message) IsFriend() bool

func (*Message) IsGroup

func (chat *Message) IsGroup() bool

func (*Message) TypeInt32

func (chat *Message) TypeInt32() int32

type Option

type Option struct {
	SyncVersion bool
	SyncData    bool
	SaveEnabled bool
}

type Package

type Package struct {
	Event   Event  `json:"event"`
	Content string `json:"content"` //json格式化
}

func (*Package) HasValid

func (pack *Package) HasValid() error

func (*Package) ToChatGroup

func (pack *Package) ToChatGroup() *GroupModel

func (*Package) ToChatMsg

func (pack *Package) ToChatMsg() *Message

Jump to

Keyboard shortcuts

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