Documentation ¶
Index ¶
- Constants
- Variables
- func AclCheck(cli *Client, cmd string) (err error)
- func CheckAndPush(channel, message, ownerId string)
- func InitAclEnv()
- func InitOffPushService() error
- func LoadUserIdsByChannel(channel string) []string
- func LoadUserIdsFromDatabase(channel string) ([]string, error)
- func Publish(channel, msg, userId string, msgId int64, fromS2s bool) string
- func PublishBinMsg(channel, ownerId string, msg []byte, isToOtherServer bool)
- func PublishStrMsg(channel, msg, ownerId string, isToOtherServer bool)
- func PushToClients(msg string, isToOtherServer bool, userIds ...string)
- func RegisterEtc() error
- func Subscribe(cli *Client, channel string) string
- func TokenCheck(cli *Cmdline) error
- func UnregisterEtc() error
- func Unsubscribe(cli *Client, channel string) string
- func UnsubscribeAllChannels(cli *Client)
- type ChannelToUserIds
- func (this *ChannelToUserIds) AddAllUserIds(channel string, freshUserIds ...string)
- func (this *ChannelToUserIds) AddUserId(channel, userId string)
- func (this *ChannelToUserIds) Exists(channel string) (exists bool)
- func (this *ChannelToUserIds) GetUserIdsByChannel(channel string) ([]string, bool)
- func (this *ChannelToUserIds) RemoveUserId(channel, userId string)
- type Client
- type Cmdline
- type ForwardTuple
- type IOffSender
- type OffSenderPool
- type Peer
- type ProxyStats
- type PubsubChans
- type PushdClientProcessor
- type PushdLongPollingServer
- func (this *PushdLongPollingServer) Launch(listenAddr string, sessTimeout time.Duration)
- func (this *PushdLongPollingServer) ServeHistory(w http.ResponseWriter, req *http.Request)
- func (this *PushdLongPollingServer) ServePublish(w http.ResponseWriter, req *http.Request)
- func (this *PushdLongPollingServer) ServeSubscribe(w http.ResponseWriter, req *http.Request)
- type Router
- type S2sClientProcessor
- type S2sProxy
- type Sender
- type ServerCmdline
- type ServerStats
- type TokenInfo
- type UserIdCollection
- type UuidClientMap
Constants ¶
View Source
const ( TYPE_CLIENT = 1 TYPE_SERVER = 2 CLIENT_STATE_CREATE = 0 CLIENT_STATE_INIT_DOEN = 1 CLIENT_STATE_DEAD = 2 )
View Source
const ( CMD_OFFLINE_MSG = "ofli_msg" CMD_CREATE_USER = "user_create" CMD_ACK_MSG = "ack" CMD_DISOLVE = "disolve" CMD_UNSUBS = "unsubs" CMD_SUBS = "subs" CMD_ADD_USER_INTO_ROOM = "add_into_room" CMD_APPKEY = "getappkey" CMD_SENDMSG = "sendmsg" CMD_SETUUID = "setuuid" CMD_SUBSCRIBE = "sub" CMD_PUBLISH = "pub" CMD_UNSUBSCRIBE = "unsub" CMD_HISTORY = "his" CMD_TOKEN = "gettoken" CMD_AUTH_CLIENT = "auth_client" CMD_AUTH_SERVER = "auth_server" CMD_PING = "ping" CMD_CREATEROOM = "create_room" CMD_JOINROOM = "join_room" CMD_LEAVEROOM = "leave_room" // 发送二进制,如语音单聊 CMD_VIDO_CHAT = "vido" // 语音、视频聊天相关(发起视频对话,接受对话,拒绝对话,发起多对多,一对一,加入视频对话) CMD_FRAME_APPLY = "frame_apply" CMD_FRAME_JOIN = "frame_join" CMD_FRAME_OUT = "frame_out" CMD_FRAME_ACCEPT = "frame_accept" CMD_FRAME_DISMISS = "frame_dismiss" CMD_FRAME_REFUSE = "frame_refuse" CMD_FRAME_INFO = "frame_info" CMD_INVOKE_FRAME_ACTION = "frame_action" CMD_RETRACT_MESSAGE = "retract_msg" // 撤回消息 CMD_UPDATE_OR_ADD_PUSH_ID = "up_ad_pushId" // app server通过im往客户端推送消息 CMD_SET_OFF_NOTIFY = "set_notify" CMD_PUBLISH_NOTIFICATION_IN_CHAT_ROOM = "pnicr" CMD_PUSH_NOTIFY_TO_USERS = "pntus" CMD_ACK_SERVER_NOTIFY = "asn" CMD_PEEK_SERVER_NOTIFY = "psn" OUTPUT_FRAME_CHAT = "FRAMECHAT" OUTPUT_TOKEN = "TOKEN" OUTPUT_AUTH_SERVER = "AUTHSERVER" OUTPUT_RCIV = "RCIV" OUTPUT_APPKEY = "APPKEY" OUTPUT_SUBSCRIBED = "SUBSCRIBED" OUTPUT_ALREADY_SUBSCRIBED = "ALREADY SUBSCRIBED" OUTPUT_NOT_SUBSCRIBED = "NOT SUBSCRIBED" OUTPUT_UNSUBSCRIBED = "UNSUBSCRIBED" OUTPUT_PONG = "pong" )
View Source
const ( TYPE_SINGLE_VOICE = 1 TYPE_MUL_VOICE = 2 TYPE_SINGLE_VIDEO = 3 TYPE_MUL_VIDEO = 4 )
TODO 思考定义了这些常量,为什么没有用上
View Source
const ( CODE_SUCCESS = 200 CODE_PARAM_ERROR = 202 CODE_SERVER_ERROR = 500 CODE_FAILED = 400 CODE_TOKEN_OR_TERM_ERROR = 508 )
TODO 所有响应消息,修改为使用code码来区别类型
View Source
const ( // 正常消息 MESSAGE_TYPE_NORMAL = 0 // 某人创建群聊 CREATE_CHAT_ROOM = 2 // 某人撤回消息 RETRACT_MESSAGE = 3 // 某人加入群聊 SOME_ONE_JOIN_CHAT_ROOM = 4 // 某人退出群聊 SOME_ONE_QUIT_CHAT_ROOM = 5 // 某人被踢出群聊 SOME_ONE_EXPELLED_FROM_CHAT_ROOM = 6 // 某人修改了群名称 SOME_ONE_MODIFY_NAME_OF_CHAT_ROOM = 7 // 某人被邀请加入群聊 SOME_ONE_BE_INVITED_OT_CHAT_ROOM = 8 // 面对面群中某人加入群聊 FACE_TO_FACE_SOME_ONE_JOIN_CHAT_ROOM = 9 // 群主变更 MASTER_CHANGE_CHAT_ROOM = 11 // 按人通知 MESSAGE_FOR_PERSON = 1000 )
数据库集合msg_log中各记录的类型
View Source
const ( RETRY_CNT = 2 S2S_SUB_CMD = "sub" S2S_PUB_CMD = "pub" S2S_UNSUB_CMD = "unsub" S2S_PUSH_BINARY_MESSAGE = "push_bin_msg" // 广播内容为二进制的消息 S2S_PUSH_STRING_MESSAGE = "push_str_msg" // 广播内容为字符型的消息 )
View Source
const (
UNSTABLE_INFO_TYPE_FRAME_CHAT = 1
)
Variables ¶
View Source
var ( PubsubChannels *PubsubChans UuidToClient *UuidClientMap )
View Source
var (
ErrNotPermit error = errors.New("Not Permit")
)
Functions ¶
func CheckAndPush ¶
func CheckAndPush(channel, message, ownerId string)
func InitAclEnv ¶
func InitAclEnv()
func InitOffPushService ¶
func InitOffPushService() error
func LoadUserIdsByChannel ¶
func LoadUserIdsFromDatabase ¶
func PublishBinMsg ¶
推送和转发二进制类型消息
func PublishStrMsg ¶
推送和转发字符类型消息
func PushToClients ¶
func RegisterEtc ¶
func RegisterEtc() error
func TokenCheck ¶
func UnregisterEtc ¶
func UnregisterEtc() error
func Unsubscribe ¶
func UnsubscribeAllChannels ¶
func UnsubscribeAllChannels(cli *Client)
Types ¶
type ChannelToUserIds ¶
存储群聊Id到群聊中用户集合的映射
func (*ChannelToUserIds) AddAllUserIds ¶
func (this *ChannelToUserIds) AddAllUserIds(channel string, freshUserIds ...string)
func (*ChannelToUserIds) AddUserId ¶
func (this *ChannelToUserIds) AddUserId(channel, userId string)
func (*ChannelToUserIds) Exists ¶
func (this *ChannelToUserIds) Exists(channel string) (exists bool)
func (*ChannelToUserIds) GetUserIdsByChannel ¶
func (this *ChannelToUserIds) GetUserIdsByChannel(channel string) ([]string, bool)
func (*ChannelToUserIds) RemoveUserId ¶
func (this *ChannelToUserIds) RemoveUserId(channel, userId string)
type Client ¶
type Client struct { Channels map[string]int Type uint8 *server.Client PushId string IsAllowForceNotify bool // contains filtered or unexported fields }
func (*Client) ClearIdentity ¶
func (this *Client) ClearIdentity()
type ForwardTuple ¶
type ForwardTuple struct {
// contains filtered or unexported fields
}
func NewForwardTuple ¶
func NewForwardTuple(peers set.Set, msg []byte, cmd string) (this *ForwardTuple)
type IOffSender ¶
type IOffSender interface {
// contains filtered or unexported methods
}
type OffSenderPool ¶
type OffSenderPool struct {
// contains filtered or unexported fields
}
func (*OffSenderPool) ObtainOneOffSender ¶
func (this *OffSenderPool) ObtainOneOffSender() IOffSender
type Peer ¶
type Peer struct {
// contains filtered or unexported fields
}
func (*Peer) WriteFormatMsg ¶
type ProxyStats ¶
type ProxyStats struct {
// contains filtered or unexported fields
}
type PubsubChans ¶
func NewPubsubChannels ¶
func NewPubsubChannels(maxChannelItems int) (this *PubsubChans)
func (*PubsubChans) Get ¶
func (this *PubsubChans) Get(channel string) (clients cmap.ConcurrentMap, exists bool)
type PushdClientProcessor ¶
type PushdClientProcessor struct {
// contains filtered or unexported fields
}
func NewPushdClientProcessor ¶
func NewPushdClientProcessor(server *server.TcpServer, serverStats *ServerStats) *PushdClientProcessor
func (*PushdClientProcessor) DisableAclCheck ¶
func (this *PushdClientProcessor) DisableAclCheck()
func (*PushdClientProcessor) EnableAclCheck ¶
func (this *PushdClientProcessor) EnableAclCheck()
func (*PushdClientProcessor) OnAccept ¶
func (this *PushdClientProcessor) OnAccept(c *server.Client)
type PushdLongPollingServer ¶
type PushdLongPollingServer struct { *server.HttpServer // contains filtered or unexported fields }
func NewPushdLongPollingServer ¶
func NewPushdLongPollingServer(name string) *PushdLongPollingServer
func (*PushdLongPollingServer) Launch ¶
func (this *PushdLongPollingServer) Launch(listenAddr string, sessTimeout time.Duration)
func (*PushdLongPollingServer) ServeHistory ¶
func (this *PushdLongPollingServer) ServeHistory(w http.ResponseWriter, req *http.Request)
func (*PushdLongPollingServer) ServePublish ¶
func (this *PushdLongPollingServer) ServePublish(w http.ResponseWriter, req *http.Request)
func (*PushdLongPollingServer) ServeSubscribe ¶
func (this *PushdLongPollingServer) ServeSubscribe(w http.ResponseWriter, req *http.Request)
type Router ¶
func (*Router) AddPeerToChannel ¶
func (*Router) LookupPeersByChannel ¶
func (*Router) RemovePeerFromChannel ¶
type S2sClientProcessor ¶
type S2sClientProcessor struct {
// contains filtered or unexported fields
}
func NewS2sClientProcessor ¶
func NewS2sClientProcessor(server *server.TcpServer) *S2sClientProcessor
func (*S2sClientProcessor) OnAccept ¶
func (this *S2sClientProcessor) OnAccept(client *server.Client)
type S2sProxy ¶
type S2sProxy struct { Router *Router ForwardTuple chan *ForwardTuple Stats *ProxyStats }
var (
Proxy *S2sProxy
)
func NewS2sProxy ¶
func NewS2sProxy() (this *S2sProxy)
type ServerCmdline ¶
func NewServerCmdline ¶
func NewServerCmdline(input []byte, cli *server.Client) (this *ServerCmdline, err error)
type ServerStats ¶
type ServerStats struct { *server.HttpJsonServer CallLatencies metrics.Histogram CallPerSecond metrics.Meter }
func NewServerStats ¶
func NewServerStats() (this *ServerStats)
type UserIdCollection ¶
type UserIdCollection struct {
// contains filtered or unexported fields
}
存储某个群聊中所有的用户的Id
type UuidClientMap ¶
type UuidClientMap struct {
// contains filtered or unexported fields
}
func NewUuidClientMap ¶
func NewUuidClientMap() (this *UuidClientMap)
func (*UuidClientMap) AddClient ¶
func (this *UuidClientMap) AddClient(uuid string, client *Client)
func (*UuidClientMap) GetClient ¶
func (this *UuidClientMap) GetClient(uuid string) (client *Client, exists bool)
func (*UuidClientMap) Remove ¶
func (this *UuidClientMap) Remove(uuid string, client *Client)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.