Documentation ¶
Index ¶
- Constants
- Variables
- func CreateAndStartGroup(redis_pool *redis.Pool, config config.ConfigBase)
- func CreateGroup(db *sql.DB, appid int64, master int64, name string, super int8) int64
- func DeleteGroup(db *sql.DB, group_id int64) bool
- func LoadAllGroup(db *sql.DB) (map[int64]*Group, error)
- func LoadGroupMember(db *sql.DB, group_id int64) (map[int64]int64, error)
- func ReadHeader(buff []byte) (int, int, int, int, int)
- func SendMessage(conn io.Writer, msg *Message) error
- func WriteHeader(len int32, seq int32, cmd byte, version byte, flag byte, buffer io.Writer)
- func WriteMessage(w *bytes.Buffer, msg *Message)
- type AppGroupMemberID
- type AppMessage
- type AppRoomID
- type AppRoute
- type AppUserID
- type AuthenticationStatus
- type AuthenticationToken
- type Command
- type CustomerMessage
- type Group
- func (group *Group) AddMember(uid int64, timestamp int)
- func (group *Group) GetMemberMute(uid int64) bool
- func (group *Group) GetMemberTimestamp(uid int64) int
- func (group *Group) IsEmpty() bool
- func (group *Group) IsMember(uid int64) bool
- func (group *Group) Members() map[int64]int64
- func (group *Group) RemoveMember(uid int64)
- func (group *Group) SetMemberMute(uid int64, mute bool)
- type GroupManager
- func (g *GroupManager) FindGroup(gid int64) *Group
- func (g *GroupManager) FindUserGroups(appid int64, uid int64) []*Group
- func (g *GroupManager) GetGroups() []*Group
- func (g *GroupManager) HandleCreate(data string)
- func (g *GroupManager) HandleDisband(data string)
- func (g *GroupManager) HandleMemberAdd(data string)
- func (g *GroupManager) HandleMemberRemove(data string)
- func (g *GroupManager) HandleMute(data string)
- func (g *GroupManager) HandleUpgrade(data string)
- func (g *GroupManager) Ping()
- func (g *GroupManager) PingLoop()
- func (g *GroupManager) ReloadGroup() bool
- func (g *GroupManager) Run()
- func (g *GroupManager) RunOnce() bool
- func (g *GroupManager) Start()
- type GroupNotification
- type GroupSyncKey
- type IMMessage
- type IMessage
- type IVersionMessage
- type IgnoreMessage
- type IntSet
- type Message
- type MessageACK
- type MessageCreator
- type MessageUnreadCount
- type RTMessage
- type Room
- type RoomMessage
- type RouteBase
- type SubscribeMessage
- type SyncKey
- type SystemMessage
- type VOIPControl
- type VersionMessageCreator
Constants ¶
View Source
const DEFAULT_VERSION = 1
View Source
const MESSAGE_FLAG_GROUP = 0x04
群组离线消息 MSG_OFFLINE使用
View Source
const MESSAGE_FLAG_SELF = 0x08
离线消息由当前登录的用户在当前设备发出
View Source
const MESSAGE_FLAG_TEXT = 0x01
消息标志 文本消息
View Source
const MESSAGE_FLAG_UNPERSISTENT = 0x02
消息不持久化
View Source
const MSG_ACK = 5
View Source
const MSG_AUTH_STATUS = 3
View Source
const MSG_AUTH_TOKEN = 15
View Source
const MSG_CUSTOMER = 24 //顾客->客服
persistent
View Source
const MSG_CUSTOMER_SERVICE_ = 23
persistent, deprecated
View Source
const MSG_CUSTOMER_SUPPORT = 25 //客服->顾客
View Source
const MSG_ENTER_ROOM = 18
View Source
const MSG_GROUP_IM = 8 //群聊IM
View Source
const MSG_GROUP_NOTIFICATION = 7 //群聊通知
persistent
View Source
const MSG_GROUP_SYNC_KEY = 35
View Source
const MSG_HEADER_SIZE = 12
View Source
const MSG_IM = 4
persistent
View Source
const MSG_LEAVE_ROOM = 19
View Source
const MSG_NOTIFICATION = 36
系统通知消息, unpersistent
View Source
const MSG_PING = 13
View Source
const MSG_PONG = 14
View Source
const MSG_PUBLISH = 132 //私聊消息
View Source
const MSG_PUBLISH_GROUP = 135 //广播给其他所有群聊服务器
View Source
const MSG_PUBLISH_ROOM = 138 //广播房间消息
View Source
const MSG_ROOM_IM = 20
View Source
const MSG_RST = 6
deprecated
View Source
const MSG_RT = 17
View Source
const MSG_SUBSCRIBE = 130 //在线请求
路由服务器消息
View Source
const MSG_SUBSCRIBE_ROOM = 136 //加入房间
View Source
const MSG_SYNC = 26 //同步消息
客户端->服务端
View Source
const MSG_SYNC_BEGIN = 27
服务端->客服端
View Source
const MSG_SYNC_END = 28
View Source
const MSG_SYNC_GROUP = 30 //同步超级群消息
客户端->服务端
View Source
const MSG_SYNC_GROUP_BEGIN = 31
服务端->客服端
View Source
const MSG_SYNC_GROUP_END = 32
View Source
const MSG_SYNC_GROUP_NOTIFY = 33
通知客户端有新消息
View Source
const MSG_SYNC_KEY = 34
客服端->服务端,更新服务器的synckey
View Source
const MSG_SYNC_NOTIFY = 29
通知客户端有新消息
View Source
const MSG_SYSTEM = 21
persistent
View Source
const MSG_UNREAD_COUNT = 22
View Source
const MSG_UNSUBSCRIBE = 131 //离线请求
View Source
const MSG_UNSUBSCRIBE_ROOM = 137 //离开房间
View Source
const MSG_VOIP_CONTROL = 64
View Source
const PLATFORM_ANDROID = 2
View Source
const PLATFORM_IOS = 1
平台号
View Source
const PLATFORM_WEB = 3
View Source
const SUBSCRIBE_HEATBEAT = 5 * 60
同redis的长链接保持5minute的心跳
Variables ¶
View Source
var Message_creators map[int]MessageCreator = make(map[int]MessageCreator)
Functions ¶
func CreateAndStartGroup ¶
func CreateAndStartGroup(redis_pool *redis.Pool, config config.ConfigBase)
func CreateGroup ¶
func WriteHeader ¶
func WriteMessage ¶
Types ¶
type AppGroupMemberID ¶
func (*AppGroupMemberID) FromData ¶
func (id *AppGroupMemberID) FromData(buff []byte) bool
func (*AppGroupMemberID) ToData ¶
func (id *AppGroupMemberID) ToData() []byte
type AppMessage ¶
type AppMessage struct { Appid int64 Receiver int64 Msgid int64 Device_id int64 Timestamp int64 //纳秒,测试消息从im->imr->im的时间 Msg *Message }
func (*AppMessage) FromData ¶
func (amsg *AppMessage) FromData(buff []byte) bool
func (*AppMessage) ToData ¶
func (amsg *AppMessage) ToData() []byte
type AppRoute ¶
type AppRoute struct { FnCreate func(appid int64) RouteBase //创建route // contains filtered or unexported fields }
func (*AppRoute) FindOrAddRoute ¶
根据id获取路由,不在路由中则创建路由加入路由管理,并返回创建的路由
type AuthenticationStatus ¶
type AuthenticationStatus struct {
Status int32
}
func (*AuthenticationStatus) FromData ¶
func (auth *AuthenticationStatus) FromData(buff []byte) bool
func (*AuthenticationStatus) ToData ¶
func (auth *AuthenticationStatus) ToData() []byte
type AuthenticationToken ¶
func (*AuthenticationToken) FromData ¶
func (auth *AuthenticationToken) FromData(buff []byte) bool
func (*AuthenticationToken) ToData ¶
func (auth *AuthenticationToken) ToData() []byte
type CustomerMessage ¶
type CustomerMessage struct { Customer_appid int64 //顾客id所在appid Customer_id int64 //顾客id Store_id int64 Seller_id int64 Timestamp int32 Content string }
func (*CustomerMessage) FromData ¶
func (cs *CustomerMessage) FromData(buff []byte) bool
func (*CustomerMessage) ToData ¶
func (cs *CustomerMessage) ToData() []byte
type Group ¶
type Group struct { Gid int64 Appid int64 Super bool //超大群 // contains filtered or unexported fields }
func (*Group) GetMemberMute ¶
func (*Group) GetMemberTimestamp ¶
func (*Group) RemoveMember ¶
func (*Group) SetMemberMute ¶
type GroupManager ¶
type GroupManager struct {
// contains filtered or unexported fields
}
群聊房间管理
var Group_manager *GroupManager
func NewGroupManager ¶
func NewGroupManager(redis_pool *redis.Pool, config config.ConfigBase) *GroupManager
func (*GroupManager) FindGroup ¶
func (g *GroupManager) FindGroup(gid int64) *Group
func (*GroupManager) FindUserGroups ¶
func (g *GroupManager) FindUserGroups(appid int64, uid int64) []*Group
func (*GroupManager) GetGroups ¶
func (g *GroupManager) GetGroups() []*Group
func (*GroupManager) HandleCreate ¶
func (g *GroupManager) HandleCreate(data string)
func (*GroupManager) HandleDisband ¶
func (g *GroupManager) HandleDisband(data string)
func (*GroupManager) HandleMemberAdd ¶
func (g *GroupManager) HandleMemberAdd(data string)
func (*GroupManager) HandleMemberRemove ¶
func (g *GroupManager) HandleMemberRemove(data string)
func (*GroupManager) HandleMute ¶
func (g *GroupManager) HandleMute(data string)
func (*GroupManager) HandleUpgrade ¶
func (g *GroupManager) HandleUpgrade(data string)
func (*GroupManager) Ping ¶
func (g *GroupManager) Ping()
func (*GroupManager) PingLoop ¶
func (g *GroupManager) PingLoop()
func (*GroupManager) ReloadGroup ¶
func (g *GroupManager) ReloadGroup() bool
func (*GroupManager) Run ¶
func (g *GroupManager) Run()
func (*GroupManager) RunOnce ¶
func (g *GroupManager) RunOnce() bool
func (*GroupManager) Start ¶
func (g *GroupManager) Start()
type GroupNotification ¶
type GroupNotification struct {
Notification string
}
func (*GroupNotification) FromData ¶
func (notification *GroupNotification) FromData(buff []byte) bool
func (*GroupNotification) ToData ¶
func (notification *GroupNotification) ToData() []byte
type GroupSyncKey ¶
func (*GroupSyncKey) FromData ¶
func (id *GroupSyncKey) FromData(buff []byte) bool
func (*GroupSyncKey) ToData ¶
func (id *GroupSyncKey) ToData() []byte
type IVersionMessage ¶
type IgnoreMessage ¶
type IgnoreMessage struct { }
保存在磁盘中但不再需要处理的消息
func (*IgnoreMessage) FromData ¶
func (ignore *IgnoreMessage) FromData(buff []byte) bool
func (*IgnoreMessage) ToData ¶
func (ignore *IgnoreMessage) ToData() []byte
type Message ¶
func ReceiveClientMessage ¶
接受客户端消息(external messages)
func ReceiveLimitMessage ¶
func ReceiveMessage ¶
type MessageACK ¶
type MessageACK struct {
Seq int32
}
func (*MessageACK) FromData ¶
func (ack *MessageACK) FromData(buff []byte) bool
func (*MessageACK) ToData ¶
func (ack *MessageACK) ToData() []byte
type MessageCreator ¶
type MessageCreator func() IMessage
type MessageUnreadCount ¶
type MessageUnreadCount struct {
Count int32
}
func (*MessageUnreadCount) FromData ¶
func (u *MessageUnreadCount) FromData(buff []byte) bool
func (*MessageUnreadCount) ToData ¶
func (u *MessageUnreadCount) ToData() []byte
type RoomMessage ¶
type RoomMessage struct {
*RTMessage
}
type SubscribeMessage ¶
func (*SubscribeMessage) FromData ¶
func (sub *SubscribeMessage) FromData(buff []byte) bool
func (*SubscribeMessage) ToData ¶
func (sub *SubscribeMessage) ToData() []byte
type SystemMessage ¶
type SystemMessage struct {
Notification string
}
func (*SystemMessage) FromData ¶
func (sys *SystemMessage) FromData(buff []byte) bool
func (*SystemMessage) ToData ¶
func (sys *SystemMessage) ToData() []byte
type VOIPControl ¶
type VOIPControl struct {
// contains filtered or unexported fields
}
func (*VOIPControl) FromData ¶
func (ctl *VOIPControl) FromData(buff []byte) bool
func (*VOIPControl) ToData ¶
func (ctl *VOIPControl) ToData() []byte
type VersionMessageCreator ¶
type VersionMessageCreator func() IVersionMessage
Click to show internal directories.
Click to hide internal directories.