Categorygithub.com/ruixueyun/ruixuego
modulepackage
0.1.40
Repository: https://github.com/ruixueyun/ruixuego.git
Documentation: pkg.go.dev

# README

瑞雪 Go 服务端 SDK

已实现功能

  • 通行证 LoginOpenID 加解密(LoginOpenID 是由瑞雪服务端在登录成功后下发的加密登录 OpenID,CP 方可通过此字段进行安全检查);
  • 自定/好友关系操作(添加、删除,修改备注);
  • 给用户设置社交模块的自定义信息;
  • LBS 相关接口;
  • 大数据埋点(参考 examples/bigdata/main.go);

使用方法

通过 go mod 引入 SDK

go get ruixuego
package main

import (
	"fmt"

	"ruixuego"
)

const (
	testAppID     = "wltestapp"
	testChannelID = "wltestchannel"
	testAppKey    = "a463deade4b15d5ac5398f97cdaeab65"
)

func main() {
	// SDK 初始化
	err := ruixuego.Init(&ruixuego.Config{
		APIDomain: "http://ruixue.weiletest.com",       // 瑞雪云接口域名 URL, 以 http[s]:// 开头
		CPID:      1000000,                             // CPID 由瑞雪团队提供
		CPKey:     "f3c7907d161764daf97fdaaea1a72261",  // CPKey 由瑞雪团队提供
		AppKeys:   map[string]map[string]string{        // CP 方应用配置
			testAppID: {
				testChannelID: testAppKey,
			},
		},
		BigData: &ruixuego.BigDataConfig{ // 要使用大数据埋点功能必须配置此参数
			AutoFlush: true,
		},
		ServiceMark: "default", // 游戏服分区信息
	})
	if err != nil {
		panic(err)
	}

	defer func() {
		// 使用大数据埋点功能上传数据后, 必须在程序退出前显式调用 ruixuego.Close()
		// 不然可能导致数据丢失
		fmt.Println("close result:", ruixuego.Close())
	}()

	// 初始化成功后通过以下方式进行接口调用
	// ruixuego.GetDefaultClient().SomeAPI()
}

# Packages

No description provided by the author
No description provided by the author
No description provided by the author

# Functions

AddAESKey 添加预置密钥.
AesDecrypt AES-CBC解密.
AesDecryptBase64String AES-CBC解密字符串.
AesDecryptWithPool AES-CBC解密.
AesEncrypt AES-CBC加密.
AesEncryptBase64String AES-CBC加密字符串.
AesEncryptWithPool AES-CBC加密.
Atoi string to int.
Atoi32 string to int32.
Atoi64 string to int64.
BytesToString 字节切片转字符串 nolint.
No description provided by the author
DecryptOpenIDData 解密 OpenIDData 密文字符串.
DecryptOpenIDDataWithKey 解密 OpenIDData 密文字符串.
DelAESKey 删除预置密钥.
EncryptOpenIDData 加密 OpenID 数据, 获取密文.
EncryptOpenIDDataWithKey 加密 OpenID 数据, 获取密文.
ErrTraceID 返回发生错误的 TraceID.
GenerateAESKey 生成 AES-256 密钥.
GenerateVirtualLoginData 生成用于虚拟登录瑞雪的登录凭证 用于未接入通行证的业务又想实用其他接口的情况 userID 参数为 CP 自己用户的唯一标识符, 一般情况下推荐使用用户 ID.
GenerateVirtualLoginDataWithKey 生成用于虚拟登录瑞雪的登录凭证.
GetArgs 获取 fasthttp 参数对象.
No description provided by the author
GetLogger 获取框架当前使用的日志处理接口.
No description provided by the author
GetRequest 获取 fasthttp 请求参数, 用于需要自定义请求头的场景.
GetSign 获取请求签名,该签名通过 sha1(TraceID+Timestamp+CPKey) 得来.
I32toa int32 转字符串.
I64toa int64 转字符串.
IMSGetCustomSingleConversationID 生成自定义单聊会话 ID.
IMSGetGroupConversationID 生成群聊会话 ID.
IMSGetSingleConversationID 生成单聊会话 ID.
IMSParseConversationID 解析 ConversationID.
IMSParseMsgID 解析 MsgID,convType 为空表示 msgID 不合规.
IMSParseSingleConversationIDData 解析单聊 ConversationIDData 小的 UserID 在前.
IMSVerifyUserID 验证 UserID 是否合规.
Init 初始化 SDK.
Itoa int 转字符串.
MarshalJSON 编码 JSON.
MarshalJSONEscapeHTML 编码 JSON, 不编码 HTML 标记字符.
NewAESData 生成加密密钥数据块.
NewAESDataWityHex 基于 64 长度的 16 进制密钥生成加密密钥数据块.
NewBool creates a Bool.
No description provided by the author
NewHTTPClient create http client.
No description provided by the author
No description provided by the author
No description provided by the author
PutResponse 将 *fasthttp.Response 返回对象池.
RegisterLogger 注册框架当前使用的日志处理接口.
SetEvent 事件名.
SetPreset 预制属性.
SetProperties 自定义属性.
SetUserUpdateType 用户更新类型:user_setonce,user_set.
StringToBytes 字符串转字节切片 需要注意的是该方法极不安全,使用过程中应足够谨慎,防止各类访问越界的问题 nolint.
UnmarshalJSON 解码 JSON.

# Constants

IMSConvTypeChannel 频道聊天 该类型主要针对游戏业务,不支持离线消息、已读、撤回等功能.
IMSConvTypeCustomSingle 自定义单聊.
IMSConvTypeGroup 群聊.
IMSConvTypeSingle 单聊.
预置 Key 定义.
预置 Key 定义.
预置 Key 定义.
预置 Key 定义.
预置 Key 定义.
预置 Key 定义.
预置 Key 定义.
预置 Key 定义.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Variables

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Structs

No description provided by the author
AESData AES 密钥缓存结构.
No description provided by the author
No description provided by the author
Bool is an atomic Boolean.
No description provided by the author
Config 瑞雪配置.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
HTTPClient a fasthttp client.
IMSChannelUsesCountReq 获取频道玩家数量.
IMSConvDeleteReq 删除会话请求参数.
IMSConversation 会话信息.
IMSConversationUserListReq 获取用户会话列表请求参数.
IMSCreateConvReq 创建会话请求参数.
IMSGetConversationReq 获取会话信息请求参数.
IMSHistoryReq 历史聊天记录请求参数.
IMSHistoryResp 历史聊天记录响应参数.
IMSJoinConversationReq 加入会话请求参数.
IMSLeaveConversationReq 离开会话请求参数.
IMSLoginReq 登录请求参数.
IMSLoginResp 登录响应参数.
IMSMessage 聊天信息定义.
IMSMessageAck 聊天消息确认响应.
IMSUpdateConvReq 更新会话信息请求参数.
IMSUpdateConvUserDataReq 更新用户在会话中的属性请求参数.
No description provided by the author
No description provided by the author
No description provided by the author
MemberInfo 会话成员属性.
OpenIDData OpenID 加密 OpenID 数据定义.
No description provided by the author
PusherPushReq 推送请求参数.
No description provided by the author
No description provided by the author
RankMember 玩家排行对象.
RealAuthReq 实名请求.
RealAuthResponse 实名结果.
No description provided by the author
ReportCustomAction 投放归因上报自定义action.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
SensitiveReq 敏感词检测请求.
SensitiveResponse 敏感词检测返回.
No description provided by the author

# Interfaces

Logger 框架内部使用日志接口定义.

# Type aliases

No description provided by the author
RelationTypes 自定义用户关系类型 map[自定义类型]是否为双向关系.