client

package
v0.0.0-...-17d8d8c Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2018 License: GPL-3.0 Imports: 11 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckNickName

func CheckNickName(nick string) (int32, error)

CheckNickName - 用户昵称校验

func CheckUserName

func CheckUserName(name string) (int32, error)

CheckUserName - 用户名校验, 用户名目前只支持邮箱, 长度至少6位

func CheckUserPassword

func CheckUserPassword(passwd string) (int32, error)

CheckUserPassword - 用户密码校验, 密码强度暂时不限制, 当前只限制密码最小长度

func DecodeContactList

func DecodeContactList(data []byte) (*meta.ContactList, error)

func DecodeFriendList

func DecodeFriendList(data []byte) (*meta.FriendList, error)

DecodeFriendList 把json数据解析成FriendList

func DecodeGroupList

func DecodeGroupList(data []byte) (*meta.GroupList, error)

DecodeGroupList 把json数据解析成GroupList

func DecodeUserInfo

func DecodeUserInfo(data []byte) (*meta.UserInfo, error)

DecodeUserInfo 把json数据解析成UserInfo

func DecodeUserList

func DecodeUserList(data []byte) (*meta.UserList, error)

DecodeUserList 把json数据解析成UserList

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) Group

func (c *CandyClient) Group(id int64, operate int32, user int64, msg string) error

Group 群操作

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) Logout

func (c *CandyClient) Logout() error

Logout 注销登陆

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) Start

func (c *CandyClient) Start() error

Start 连接服务端.

func (*CandyClient) Stop

func (c *CandyClient) Stop()

Stop 关连接,退出

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

type Error struct {
	Code int32
	Msg  string
	Data string
}

Error 返回错误

func ErrorParse

func ErrorParse(msg string) *Error

ErrorParse - parse error string to an Error object

func NewData

func NewData(code int32, msg string, data string) *Error

NewData - create an data Error

func NewError

func NewError(code int32, msg string) *Error

NewError - create an new Error

func (*Error) Error

func (e *Error) Error() string

Error - implement error interface

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 接收服务器端推送来的消息

Jump to

Keyboard shortcuts

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