-
Notifications
You must be signed in to change notification settings - Fork 4
/
connection_info.go
167 lines (143 loc) · 4.02 KB
/
connection_info.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
package altv
/*
#include <stdlib.h>
#include "capi.h"
*/
import "C"
import (
"unsafe"
"github.com/timo972/altv-go/internal/lib"
)
/*type ConnectionInfo interface {
// ID returns the id of the connecting player
ID() uint32
// Name returns the name of the connecting player
Name() string
// SocialID returns the social id of the connecting player
SocialID() uint64
// SocialName returns the social name of the connecting player
SocialName() string
// HwIdHash returns the harware id hash of the connecting player
HwIdHash() uint64
// HwIdExHash returns the extended harware id hash of the connecting player
HwIdExHash() uint64
// AuthToken returns the auth token of the connecting player
AuthToken() string
// Debug returns if the connecting player uses debug mode
Debug() bool
// Branch returns the branch of the connecting player's client
Branch() string
// Build returns the build of the connecting player's client
Build() uint32
// CDNUrl returns the cdn url
CDNUrl() string
// PasswordHash returns the hash of the password the player entered
PasswordHash() uint64
// IP returns the ip of the connecting player
IP() string
// DiscordUserID returns the discord user id of the connecting player
DiscordUserID() int64
// CloudAuthHash returns the cloud auth hash of the connecting player
CloudAuthHash() string
// Accept accepts the connection and lets the player join
Accept(sendNames bool)
// Decline declines the connection and disconnects the player
Decline(reason string)
// Accepted returns if the connection was accepted
Accepted() bool
}*/
type ConnectionInfo struct {
ptr unsafe.Pointer
id uint32
name string
socialID uint64
socialName string
hwidHash uint64
hwidExHash uint64
authToken string
isDebug bool
branch string
build uint32
cdnUrl string
passwordHash uint64
ip string
discordUserID int64
cloudAuthHash string
}
// NewConnectionInfo ! INTERNAL ONLY !
func NewConnectionInfo(ptr unsafe.Pointer, id uint32, name string, socialID uint64, socialName string, hwidHash uint64, hwidExHash uint64, authToken string, debug bool, branch string, build uint32, cdnUrl string, passwordHash uint64, ip string, discordUserId int64, cloudAuthHash string) *ConnectionInfo {
return &ConnectionInfo{
ptr: ptr,
id: id,
name: name,
socialID: socialID,
socialName: socialName,
hwidHash: hwidHash,
hwidExHash: hwidExHash,
authToken: authToken,
isDebug: debug,
branch: branch,
build: build,
cdnUrl: cdnUrl,
passwordHash: passwordHash,
ip: ip,
discordUserID: discordUserId,
cloudAuthHash: cloudAuthHash,
}
}
func (c *ConnectionInfo) ID() uint32 {
return c.id
}
func (c *ConnectionInfo) Name() string {
return c.name
}
func (c *ConnectionInfo) SocialID() uint64 {
return c.socialID
}
func (c *ConnectionInfo) SocialName() string {
return c.socialName
}
func (c *ConnectionInfo) HwIdHash() uint64 {
return c.hwidHash
}
func (c *ConnectionInfo) HwIdExHash() uint64 {
return c.hwidExHash
}
func (c *ConnectionInfo) AuthToken() string {
return c.authToken
}
func (c *ConnectionInfo) Debug() bool {
return c.isDebug
}
func (c *ConnectionInfo) Branch() string {
return c.branch
}
func (c *ConnectionInfo) Build() uint32 {
return c.build
}
func (c *ConnectionInfo) CDNUrl() string {
return c.cdnUrl
}
func (c *ConnectionInfo) PasswordHash() uint64 {
return c.passwordHash
}
func (c *ConnectionInfo) IP() string {
return c.ip
}
func (c *ConnectionInfo) DiscordUserID() int64 {
return c.discordUserID
}
func (c *ConnectionInfo) CloudAuthHash() string {
return c.cloudAuthHash
}
func (c *ConnectionInfo) Accept(sendNames bool) {
C.connection_accept(c.ptr, C.uchar(lib.Bool2int(sendNames)))
}
func (c *ConnectionInfo) Decline(reason string) {
r := C.CString(reason)
defer C.free(unsafe.Pointer(r))
C.connection_decline(c.ptr, r)
}
func (c *ConnectionInfo) Accepted() bool {
return int(C.connection_is_accepted(c.ptr)) == 1
}