Documentation
¶
Index ¶
- func CheckNickName(nick string) (int32, error)
- func CheckUserName(name string) (int32, error)
- func CheckUserPassword(passwd string) (int32, error)
- func DecodeContactList(data []byte) (*meta.ContactList, error)
- func DecodeFriendList(data []byte) (*meta.FriendList, error)
- func DecodeGroupList(data []byte) (*meta.GroupList, error)
- func DecodeUserInfo(data []byte) (*meta.UserInfo, error)
- func DecodeUserList(data []byte) (*meta.UserList, error)
- type CandyClient
- func (c *CandyClient) CreateGroup(name string) (int64, error)
- func (c *CandyClient) DeleteGroup(id int64) error
- func (c *CandyClient) FileDownload(key string) ([]byte, error)
- func (c *CandyClient) FileExist(key string) (bool, error)
- func (c *CandyClient) FileUpload(data []byte) (string, error)
- func (c *CandyClient) FindUser(user string) (string, error)
- func (c *CandyClient) Friend(userID int64, operate int32, msg string) error
- func (c *CandyClient) GetUserInfoByID(userID int64) (string, error)
- func (c *CandyClient) GetUserInfoByName(user string) (string, error)
- func (c *CandyClient) Group(id int64, operate int32, user int64, msg string) error
- func (c *CandyClient) LoadFriendList() (string, error)
- func (c *CandyClient) LoadGroupList() (string, error)
- func (c *CandyClient) LoadMessage(id int64) (string, error)
- func (c *CandyClient) LoadRecentContact() (string, error)
- func (c *CandyClient) Login(user, passwd string) (int64, error)
- func (c *CandyClient) Logout() error
- func (c *CandyClient) OnNetStateChange()
- func (c *CandyClient) Register(user, passwd string) (int64, error)
- func (c *CandyClient) SendMessage(group, to int64, body string) (int64, error)
- func (c *CandyClient) Start() error
- func (c *CandyClient) Stop()
- func (c *CandyClient) UpdateUserInfo(user, nickName, avatar string) error
- func (c *CandyClient) UpdateUserPassword(user, passwd string) error
- func (c *CandyClient) UpdateUserSignature(name, signature string) error
- type Error
- type MessageHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckUserName ¶
CheckUserName - 用户名校验, 用户名目前只支持邮箱, 长度至少6位
func CheckUserPassword ¶
CheckUserPassword - 用户密码校验, 密码强度暂时不限制, 当前只限制密码最小长度
func DecodeContactList ¶
func DecodeContactList(data []byte) (*meta.ContactList, error)
func DecodeFriendList ¶
func DecodeFriendList(data []byte) (*meta.FriendList, error)
DecodeFriendList 把json数据解析成FriendList
func DecodeGroupList ¶
DecodeGroupList 把json数据解析成GroupList
func DecodeUserInfo ¶
DecodeUserInfo 把json数据解析成UserInfo
Types ¶
type CandyClient ¶
type CandyClient struct {
// contains filtered or unexported fields
}
CandyClient 客户端提供和服务器交互的接口
func NewCandyClient ¶
func NewCandyClient(dev, host string, handler MessageHandler) *CandyClient
NewCandyClient - create an new CandyClient
func (*CandyClient) CreateGroup ¶
func (c *CandyClient) CreateGroup(name string) (int64, error)
CreateGroup 创建群组
func (*CandyClient) DeleteGroup ¶
func (c *CandyClient) DeleteGroup(id int64) error
DeleteGroup 解散群组
func (*CandyClient) FileDownload ¶
func (c *CandyClient) FileDownload(key string) ([]byte, error)
FileDownload 文件下载
func (*CandyClient) FileExist ¶
func (c *CandyClient) FileExist(key string) (bool, error)
FileExist 判断文件是否存在
func (*CandyClient) FileUpload ¶
func (c *CandyClient) FileUpload(data []byte) (string, error)
FileUpload 文件上传
func (*CandyClient) FindUser ¶
func (c *CandyClient) FindUser(user string) (string, error)
FindUser 支持模糊查询,返回对应用户的列表
func (*CandyClient) Friend ¶
func (c *CandyClient) Friend(userID int64, operate int32, msg string) error
Friend 添加好友
func (*CandyClient) GetUserInfoByID ¶
func (c *CandyClient) GetUserInfoByID(userID int64) (string, error)
GetUserInfoByID 根据用户ID获取用户信息 TODO 需要把返回字符串修改成对应的类型
func (*CandyClient) GetUserInfoByName ¶
func (c *CandyClient) GetUserInfoByName(user string) (string, error)
GetUserInfoByName 根据用户名获取用户信息 TODO 需要把返回字符串修改成对应的类型
func (*CandyClient) LoadFriendList ¶
func (c *CandyClient) LoadFriendList() (string, error)
LoadFriendList 加载好友列表
func (*CandyClient) LoadGroupList ¶
func (c *CandyClient) LoadGroupList() (string, error)
LoadGroupList 拉取群组列表
func (*CandyClient) LoadMessage ¶
func (c *CandyClient) LoadMessage(id int64) (string, error)
LoadMessage 加载离线消息
func (*CandyClient) LoadRecentContact ¶
func (c *CandyClient) LoadRecentContact() (string, error)
LoadRecentContact 加载最近联系人列表
func (*CandyClient) Login ¶
func (c *CandyClient) Login(user, passwd string) (int64, error)
Login 用户登陆, 如果发生连接断开,一定要重新登录
func (*CandyClient) OnNetStateChange ¶
func (c *CandyClient) OnNetStateChange()
OnNetStateChange 移动端如果网络状态发生变化要通知这边
func (*CandyClient) Register ¶
func (c *CandyClient) Register(user, passwd string) (int64, error)
Register 用户注册接口
func (*CandyClient) SendMessage ¶
func (c *CandyClient) SendMessage(group, to int64, body string) (int64, error)
SendMessage 向服务器发送消息.
func (*CandyClient) UpdateUserInfo ¶
func (c *CandyClient) UpdateUserInfo(user, nickName, avatar string) error
UpdateUserInfo 更新用户信息, 昵称/头像
func (*CandyClient) UpdateUserPassword ¶
func (c *CandyClient) UpdateUserPassword(user, passwd string) error
UpdateUserPassword 更新用户密码
func (*CandyClient) UpdateUserSignature ¶
func (c *CandyClient) UpdateUserSignature(name, signature string) error
UpdateUserSignature 更新用户签名
type Error ¶
Error 返回错误
func ErrorParse ¶
ErrorParse - parse error string to an Error object
type MessageHandler ¶
type MessageHandler interface {
// OnRecv 这函数理论上是多线程调用,客户端需要注意下
OnRecv(event int32, operate int32, ID int64, group int64, from int64, to int64, body string)
// OnError 连接被服务器断开,或其它错误
OnError(msg string)
// OnHealth 连接正常
OnHealth()
// OnUnHealth 连接异常
OnUnHealth(msg string)
}
MessageHandler 接收服务器端推送来的消息