Documentation ¶
Index ¶
- Constants
- Variables
- func GenRandString(length int64) string
- func Sn() uint64
- type AccountInfo
- type ChatroomMessage
- type ChatroomService
- func (this *ChatroomService) GetMessage(roomid string, ids []int64) bool
- func (this *ChatroomService) HandleGetMessage(msg *UserMessage) bool
- func (this *ChatroomService) HandleServiceMessage(data []byte, sn uint64, source int) bool
- func (this *ChatroomService) Join(roomid string) uint64
- func (this *ChatroomService) Logout()
- func (this *ChatroomService) Query(roomid string, memberIndex, count int32) uint64
- func (this *ChatroomService) Quit(roomid string) uint64
- func (this *ChatroomService) Register(conn *LongLiveConn) (int, error)
- type ClientConf
- type Dumper
- type GroupService
- func (this *GroupService) GetMessage(roomid string, ids []int64) bool
- func (gs *GroupService) GetMsg(groupid string, startid uint64, offset int32)
- func (gs *GroupService) GetMsgM(ids []int64)
- func (this *GroupService) HandleGetMessage(msg *UserMessage) bool
- func (gs *GroupService) HandleServiceMessage(data []byte, sn uint64, source int) bool
- func (gs *GroupService) Register(conn *LongLiveConn) (int, error)
- func (gs *GroupService) Sync(groups []string)
- type JoinResp
- type LongLiveConn
- func (this *LongLiveConn) GetMultiInfo(infoType string, ids []int64, sparameter []byte) bool
- func (this *LongLiveConn) Register(service ServiceHandler) bool
- func (this *LongLiveConn) SendServiceMessage(serviceID int, data []byte) uint64
- func (this *LongLiveConn) SetDumpStream(value bool)
- func (this *LongLiveConn) Start(ch chan string)
- type MemberChangedNotifcation
- type MessageMeter
- type MessageSender
- func (this *MessageSender) SendChatroomMessage(roomid, sender string, content []byte, ...) (string, error)
- func (this *MessageSender) SendImMessage(receivers string, content []byte, expiration, priority, appid int) (string, error)
- func (this *MessageSender) SendPeerMessage(receivers string, content []byte, expiration, priority, appid int) (string, error)
- func (this *MessageSender) SendPublicMessage(content []byte, appid int) (string, error)
- func (this *MessageSender) SendRobotJoinMessage(roomid, userid string) (string, error)
- func (this *MessageSender) SendRobotQuitMessage(roomid, userid string) (string, error)
- type QueryResp
- type QuitResp
- type ServiceHandler
- type Stream
- type TcpStream
- type TestMessage
- type UserMessage
- type WebSocketStream
Constants ¶
const (
ChatroomServiceID = 10000006
)
const (
GroupServiceID = 10000001
)
Variables ¶
var (
DefaultMessageMeter = &MessageMeter{wrapMessage: true}
)
Functions ¶
func GenRandString ¶
Types ¶
type AccountInfo ¶
type AccountInfo struct { AccountType string // Account Type ID string // User ID PWD string // Corresponding password Sig string // Signature to obtain token DID string // Device ID Plf string // Platform NE bool // Not Encrypt }
func (*AccountInfo) IsValid ¶
func (this *AccountInfo) IsValid() bool
type ChatroomMessage ¶
type ChatroomMessage struct { Sn uint64 ID uint32 MaxID uint32 RoomID string Sender string MsgType int32 Content []byte RegisteredMemberCnt int32 // 注册用户人数 TotalMemberCnt int32 // 总人数 Valid bool // 是否有效 }
聊天室消息
type ChatroomService ¶
type ChatroomService struct {
// contains filtered or unexported fields
}
func NewChatroom ¶
func NewChatroom() *ChatroomService
func (*ChatroomService) GetMessage ¶
func (this *ChatroomService) GetMessage(roomid string, ids []int64) bool
get chatroom message
func (*ChatroomService) HandleGetMessage ¶
func (this *ChatroomService) HandleGetMessage(msg *UserMessage) bool
func (*ChatroomService) HandleServiceMessage ¶
func (this *ChatroomService) HandleServiceMessage(data []byte, sn uint64, source int) bool
func (*ChatroomService) Join ¶
func (this *ChatroomService) Join(roomid string) uint64
join in a chatroom return positive sequence number to match coressponding async response, returning zero means failure
func (*ChatroomService) Logout ¶
func (this *ChatroomService) Logout()
func (*ChatroomService) Query ¶
func (this *ChatroomService) Query(roomid string, memberIndex, count int32) uint64
query information of a specific room memberIndex and count are used to specify the range of members whose information should be retrieved return positive sequence number to match coressponding async response, returning zero means failure
func (*ChatroomService) Quit ¶
func (this *ChatroomService) Quit(roomid string) uint64
quit from a room return positive sequence number to match coressponding async response, returning zero means failure
func (*ChatroomService) Register ¶
func (this *ChatroomService) Register(conn *LongLiveConn) (int, error)
type ClientConf ¶
type ClientConf struct { ConnType string // Connection Type: "tcp", "websocket" or "wss" Addr string // Server address AppID int // ApplicationID CV int // ClientVersion PV int // ProtocolVersion DK string // Default Key HeartItvl int // Heartbeat interval (unit second) SendHeartBeat int // Send heart beat or not. if 0, not send, else send. Autologin int // auto login after init login CheckLoginWhenJoin int // check login when join chatroom }
func (*ClientConf) IsValid ¶
func (this *ClientConf) IsValid() bool
type GroupService ¶
type GroupService struct {
// contains filtered or unexported fields
}
func NewGroup ¶
func NewGroup() *GroupService
func (*GroupService) GetMessage ¶
func (this *GroupService) GetMessage(roomid string, ids []int64) bool
get chatroom message
func (*GroupService) GetMsg ¶
func (gs *GroupService) GetMsg(groupid string, startid uint64, offset int32)
func (*GroupService) GetMsgM ¶
func (gs *GroupService) GetMsgM(ids []int64)
func (*GroupService) HandleGetMessage ¶
func (this *GroupService) HandleGetMessage(msg *UserMessage) bool
func (*GroupService) HandleServiceMessage ¶
func (gs *GroupService) HandleServiceMessage(data []byte, sn uint64, source int) bool
func (*GroupService) Register ¶
func (gs *GroupService) Register(conn *LongLiveConn) (int, error)
func (*GroupService) Sync ¶
func (gs *GroupService) Sync(groups []string)
type JoinResp ¶
type JoinResp struct { Sn uint64 Result int32 Reason []byte PartnerData []byte RoomID string Members []string TotalMemberCnt int32 }
加入聊天室的响应
type LongLiveConn ¶
type LongLiveConn struct {
// contains filtered or unexported fields
}
func New ¶
func New(clientConf ClientConf, accountConf AccountInfo) (*LongLiveConn, *error)
func (*LongLiveConn) GetMultiInfo ¶
func (this *LongLiveConn) GetMultiInfo(infoType string, ids []int64, sparameter []byte) bool
GetMultiInfo, so far it is used to get chatroom message
func (*LongLiveConn) Register ¶
func (this *LongLiveConn) Register(service ServiceHandler) bool
Register a service on long live connection Corresponding data pakcet would be delivery to the service if matches TODO concurrent access unsafe
func (*LongLiveConn) SendServiceMessage ¶
func (this *LongLiveConn) SendServiceMessage(serviceID int, data []byte) uint64
Send Service Message
func (*LongLiveConn) SetDumpStream ¶
func (this *LongLiveConn) SetDumpStream(value bool)
enable the switch to print data stream
type MemberChangedNotifcation ¶
type MemberChangedNotifcation struct { RoomID string Action string Sn uint64 TotalMemberCnt int32 Members []string }
成员变化通知
type MessageMeter ¶
type MessageMeter struct {
// contains filtered or unexported fields
}
func (*MessageMeter) Check ¶
func (mm *MessageMeter) Check(content string) bool
func (*MessageMeter) EnableWrapper ¶
func (mm *MessageMeter) EnableWrapper(enable bool)
func (*MessageMeter) WrapMessage ¶
func (mm *MessageMeter) WrapMessage(content string) string
type MessageSender ¶
type MessageSender struct { PeerUrl string ChatroomUrl string RobotJoinUrl string RobotQuitUrl string PublicUrl string IMUrl string }
invoke HTTP interface to send peer|public|im|chatroom messages
func NewMessageSender ¶
func NewMessageSender(center string) (*MessageSender, error)
func (*MessageSender) SendChatroomMessage ¶
func (*MessageSender) SendImMessage ¶
func (*MessageSender) SendPeerMessage ¶
func (this *MessageSender) SendPeerMessage(receivers string, content []byte, expiration, priority, appid int) (string, error)
访问为POST方式
post数据内容:&m=111&b=Jm1zZz0xMjM0NV90ZXN0JnRyYWNlaWQ9MTIzNDU2Nzg5MCZyZWNlaXZlcnM9amlkXzEwMDAmc2VuZGVyPWppZF8yMDAw 示例数据中b的内容为&msg=12345_test&traceid=1234567890&receivers=jid_1000&sender=jid_2000的base64编码 请注意traceid的范围是无符号32位整数的范围 m的值是b的未编码内容加上"wpms"后计算出来的md5,目前没有打开校验,可以随便填
返回值为json格式字符串 {"code":0,"reason":"ok","ios_offline_users":[],"msgids":[{"owner":"jid_1000","id":113,"box":"inbox"},{"owner":"jid_2000","id":24,"box":"outbox"}]}
func (*MessageSender) SendPublicMessage ¶
func (this *MessageSender) SendPublicMessage(content []byte, appid int) (string, error)
func (*MessageSender) SendRobotJoinMessage ¶
func (this *MessageSender) SendRobotJoinMessage(roomid, userid string) (string, error)
func (*MessageSender) SendRobotQuitMessage ¶
func (this *MessageSender) SendRobotQuitMessage(roomid, userid string) (string, error)
type QueryResp ¶
type QueryResp struct { RoomID string Sn uint64 Result int32 TotalMemberCnt int32 Members []string }
聊天室详情
type ServiceHandler ¶
type ServiceHandler interface { HandleServiceMessage(data []byte, sn uint64, source int) bool HandleGetMessage(msg *UserMessage) bool Register(*LongLiveConn) (int, error) }
type TestMessage ¶
type UserMessage ¶
type WebSocketStream ¶
type WebSocketStream struct {
// contains filtered or unexported fields
}
func NewWebSocketSecurityStream ¶
func NewWebSocketSecurityStream(addr string, timeout time.Duration) (*WebSocketStream, error)
func NewWebSocketStream ¶
func NewWebSocketStream(addr string, timeout time.Duration) (*WebSocketStream, error)
func (*WebSocketStream) Close ¶
func (ws *WebSocketStream) Close()
func (*WebSocketStream) SetReadDeadline ¶
func (ws *WebSocketStream) SetReadDeadline(t time.Time) error
func (*WebSocketStream) SetWriteDeadline ¶
func (ws *WebSocketStream) SetWriteDeadline(t time.Time) error