-
Notifications
You must be signed in to change notification settings - Fork 5
/
lobbyclientfactory.go
36 lines (30 loc) · 1.16 KB
/
lobbyclientfactory.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
// Copyright (c) 2021 AccelByte Inc. All Rights Reserved.
// This is licensed software from AccelByte Inc, for limitations
// and restrictions contact your company contract manager.
package factory
import (
"strings"
"github.com/AccelByte/accelbyte-go-sdk/lobby-sdk/pkg/lobbyclient"
"github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/repository"
"github.com/AccelByte/accelbyte-go-sdk/services-api/pkg/utils"
)
var lobbyClientInstance *lobbyclient.JusticeLobbyService
func NewLobbyClient(configRepository repository.ConfigRepository) *lobbyclient.JusticeLobbyService {
if lobbyClientInstance == nil {
baseURL := configRepository.GetJusticeBaseUrl()
xAmazonTraceID := utils.AmazonTraceIDGen()
userAgent := utils.UserAgentGen()
if len(baseURL) > 0 {
baseURLSplit := strings.Split(baseURL, "://")
httpClientConfig := &lobbyclient.TransportConfig{
Host: baseURLSplit[1],
BasePath: "",
Schemes: []string{baseURLSplit[0]},
}
lobbyClientInstance = lobbyclient.NewHTTPClientWithConfig(nil, httpClientConfig, userAgent, xAmazonTraceID)
} else {
lobbyClientInstance = lobbyclient.NewHTTPClient(nil)
}
}
return lobbyClientInstance
}