-
Notifications
You must be signed in to change notification settings - Fork 0
/
ruixue.go
44 lines (34 loc) · 891 Bytes
/
ruixue.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright (c) 2021. Homeland Interactive Technology Ltd. All rights reserved.
// Package ruixuego 瑞雪服务端 SDK
package ruixuego
import "fmt"
const Version = "v0.1.31"
var config *Config
// Init 初始化 SDK
func Init(conf *Config) (err error) {
conf.done()
config = conf
defaultClient, err = NewClient()
if err != nil {
return err
}
return loadAppKeys(config.AppKeys)
}
func loadAppKeys(m map[string]map[string]string) error {
for productID, channelKeys := range m {
for channelID, appKey := range channelKeys {
err := AddAESKey(productID, channelID, []byte(appKey))
if err != nil {
return fmt.Errorf("invalid appkey: %s, productid: %s, channelid: %s, error: %s",
appKey, productID, channelID, err.Error())
}
}
}
return nil
}
func GetDefaultClient() *Client {
return defaultClient
}
func Close() error {
return defaultClient.Close()
}