made changes
This commit is contained in:
parent
9b931b0a98
commit
d1d2b4bd4a
@ -1,29 +1,27 @@
|
||||
package tsgo
|
||||
|
||||
// Ts3pluginName Name of the plugin
|
||||
func Ts3pluginName() string {
|
||||
return "Go Plugin Yay"
|
||||
type AnyId uint16
|
||||
type PluginMessageTarget int
|
||||
|
||||
type Ts3FunctionsStruct struct {
|
||||
PrintMessage func(uint64, string, PluginMessageTarget)
|
||||
}
|
||||
|
||||
// Ts3pluginVersion Version of the plugin
|
||||
func Ts3pluginVersion() string {
|
||||
return "1.0"
|
||||
}
|
||||
const (
|
||||
PLUGIN_MESSAGE_TARGET_SERVER PluginMessageTarget = 0
|
||||
PLUGIN_MESSAGE_TARGET_CHANNEL PluginMessageTarget = 1
|
||||
)
|
||||
|
||||
// Ts3pluginAPIVersion API version of the plugin
|
||||
func Ts3pluginAPIVersion() int {
|
||||
return 23
|
||||
}
|
||||
const (
|
||||
PluginName = "Go Plugin yay"
|
||||
PluginVersion = "1.0"
|
||||
PluginAuthor = "Author"
|
||||
PluginDescription = "Description"
|
||||
)
|
||||
|
||||
// Ts3pluginAuthor Plugin author
|
||||
func Ts3pluginAuthor() string {
|
||||
return "Author"
|
||||
}
|
||||
|
||||
// Ts3pluginDescription Plugin description
|
||||
func Ts3pluginDescription() string {
|
||||
return "Description"
|
||||
}
|
||||
var (
|
||||
Ts3Functions Ts3FunctionsStruct
|
||||
)
|
||||
|
||||
//Ts3pluginInit init plugin function
|
||||
func Ts3pluginInit() int {
|
||||
@ -34,3 +32,13 @@ func Ts3pluginInit() int {
|
||||
func Ts3pluginShutdown() {
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
Events
|
||||
*/
|
||||
|
||||
// Ts3onClientPokeEvent event
|
||||
func Ts3onClientPokeEvent(serverConnectionHandlerID uint64, fromClientID AnyId, pokerName string, pokerUniqueIdentity string, message string, ffIgnored int) int {
|
||||
Ts3Functions.PrintMessage(serverConnectionHandlerID, "Ayy", PLUGIN_MESSAGE_TARGET_SERVER)
|
||||
return 1
|
||||
}
|
||||
|
@ -23,31 +23,35 @@ func main() {} // Required if you want to export functions
|
||||
|
||||
//export GoTs3pluginName
|
||||
func GoTs3pluginName() *C.char {
|
||||
return C.CString(tsgo.Ts3pluginName())
|
||||
return C.CString(tsgo.PluginName)
|
||||
}
|
||||
|
||||
//export GoTs3pluginVersion
|
||||
func GoTs3pluginVersion() *C.char {
|
||||
return C.CString(tsgo.Ts3pluginVersion())
|
||||
return C.CString(tsgo.PluginVersion)
|
||||
}
|
||||
|
||||
//export GoTs3pluginAPIVersion
|
||||
func GoTs3pluginAPIVersion() C.int {
|
||||
return C.int(tsgo.Ts3pluginAPIVersion())
|
||||
return C.int(23)
|
||||
}
|
||||
|
||||
//export GoTs3pluginAuthor
|
||||
func GoTs3pluginAuthor() *C.char {
|
||||
return C.CString(tsgo.Ts3pluginAuthor())
|
||||
return C.CString(tsgo.PluginAuthor)
|
||||
}
|
||||
|
||||
//export GoTs3pluginDescription
|
||||
func GoTs3pluginDescription() *C.char {
|
||||
return C.CString(tsgo.Ts3pluginDescription())
|
||||
return C.CString(tsgo.PluginDescription)
|
||||
}
|
||||
|
||||
//export GoTs3pluginInit
|
||||
func GoTs3pluginInit() C.int {
|
||||
tsgo.Ts3Functions = tsgo.Ts3FunctionsStruct{
|
||||
PrintMessage: ts3FncPrintMessage,
|
||||
}
|
||||
|
||||
return C.int(tsgo.Ts3pluginInit())
|
||||
}
|
||||
|
||||
@ -61,7 +65,19 @@ func GoTs3pluginShutdown() {
|
||||
*/
|
||||
|
||||
//export GoTs3onClientPokeEvent
|
||||
func GoTs3onClientPokeEvent(serverConnectionHandlerID C.uint64, fromClientID C.anyID, pokerName *C.char, pokerUniqueIdentity *C.char, message *C.char, ffIgnored int) C.int {
|
||||
C.Ts3FncPrintMessage(serverConnectionHandlerID, C.CString("Ayyyy"), C.PLUGIN_SERVER)
|
||||
return 1
|
||||
func GoTs3onClientPokeEvent(serverConnectionHandlerID C.uint64, fromClientID C.anyID, pokerName *C.char, pokerUniqueIdentity *C.char, message *C.char, ffIgnored C.int) C.int {
|
||||
return C.int(tsgo.Ts3onClientPokeEvent(uint64(serverConnectionHandlerID), tsgo.AnyId(fromClientID), C.GoString(pokerName), C.GoString(pokerUniqueIdentity), C.GoString(message), int(ffIgnored)))
|
||||
}
|
||||
|
||||
/*
|
||||
Ts3 Function wrapper
|
||||
*/
|
||||
|
||||
func ts3FncPrintMessage(serverConnectionHandlerID uint64, message string, messageTarget tsgo.PluginMessageTarget) {
|
||||
switch messageTarget {
|
||||
case tsgo.PLUGIN_MESSAGE_TARGET_CHANNEL:
|
||||
C.Ts3FncPrintMessage(C.uint64(serverConnectionHandlerID), C.CString(message), C.PLUGIN_MESSAGE_TARGET_CHANNEL)
|
||||
case tsgo.PLUGIN_MESSAGE_TARGET_SERVER:
|
||||
C.Ts3FncPrintMessage(C.uint64(serverConnectionHandlerID), C.CString(message), C.PLUGIN_MESSAGE_TARGET_SERVER)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user