made changes

This commit is contained in:
Niklas 2020-09-05 13:55:36 +02:00
parent 9b931b0a98
commit d1d2b4bd4a
2 changed files with 52 additions and 28 deletions

View File

@ -1,29 +1,27 @@
package tsgo package tsgo
// Ts3pluginName Name of the plugin type AnyId uint16
func Ts3pluginName() string { type PluginMessageTarget int
return "Go Plugin Yay"
type Ts3FunctionsStruct struct {
PrintMessage func(uint64, string, PluginMessageTarget)
} }
// Ts3pluginVersion Version of the plugin const (
func Ts3pluginVersion() string { PLUGIN_MESSAGE_TARGET_SERVER PluginMessageTarget = 0
return "1.0" PLUGIN_MESSAGE_TARGET_CHANNEL PluginMessageTarget = 1
} )
// Ts3pluginAPIVersion API version of the plugin const (
func Ts3pluginAPIVersion() int { PluginName = "Go Plugin yay"
return 23 PluginVersion = "1.0"
} PluginAuthor = "Author"
PluginDescription = "Description"
)
// Ts3pluginAuthor Plugin author var (
func Ts3pluginAuthor() string { Ts3Functions Ts3FunctionsStruct
return "Author" )
}
// Ts3pluginDescription Plugin description
func Ts3pluginDescription() string {
return "Description"
}
//Ts3pluginInit init plugin function //Ts3pluginInit init plugin function
func Ts3pluginInit() int { func Ts3pluginInit() int {
@ -34,3 +32,13 @@ func Ts3pluginInit() int {
func Ts3pluginShutdown() { 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
}

View File

@ -23,31 +23,35 @@ func main() {} // Required if you want to export functions
//export GoTs3pluginName //export GoTs3pluginName
func GoTs3pluginName() *C.char { func GoTs3pluginName() *C.char {
return C.CString(tsgo.Ts3pluginName()) return C.CString(tsgo.PluginName)
} }
//export GoTs3pluginVersion //export GoTs3pluginVersion
func GoTs3pluginVersion() *C.char { func GoTs3pluginVersion() *C.char {
return C.CString(tsgo.Ts3pluginVersion()) return C.CString(tsgo.PluginVersion)
} }
//export GoTs3pluginAPIVersion //export GoTs3pluginAPIVersion
func GoTs3pluginAPIVersion() C.int { func GoTs3pluginAPIVersion() C.int {
return C.int(tsgo.Ts3pluginAPIVersion()) return C.int(23)
} }
//export GoTs3pluginAuthor //export GoTs3pluginAuthor
func GoTs3pluginAuthor() *C.char { func GoTs3pluginAuthor() *C.char {
return C.CString(tsgo.Ts3pluginAuthor()) return C.CString(tsgo.PluginAuthor)
} }
//export GoTs3pluginDescription //export GoTs3pluginDescription
func GoTs3pluginDescription() *C.char { func GoTs3pluginDescription() *C.char {
return C.CString(tsgo.Ts3pluginDescription()) return C.CString(tsgo.PluginDescription)
} }
//export GoTs3pluginInit //export GoTs3pluginInit
func GoTs3pluginInit() C.int { func GoTs3pluginInit() C.int {
tsgo.Ts3Functions = tsgo.Ts3FunctionsStruct{
PrintMessage: ts3FncPrintMessage,
}
return C.int(tsgo.Ts3pluginInit()) return C.int(tsgo.Ts3pluginInit())
} }
@ -61,7 +65,19 @@ func GoTs3pluginShutdown() {
*/ */
//export GoTs3onClientPokeEvent //export GoTs3onClientPokeEvent
func GoTs3onClientPokeEvent(serverConnectionHandlerID C.uint64, fromClientID C.anyID, pokerName *C.char, pokerUniqueIdentity *C.char, message *C.char, ffIgnored int) C.int { func GoTs3onClientPokeEvent(serverConnectionHandlerID C.uint64, fromClientID C.anyID, pokerName *C.char, pokerUniqueIdentity *C.char, message *C.char, ffIgnored C.int) C.int {
C.Ts3FncPrintMessage(serverConnectionHandlerID, C.CString("Ayyyy"), C.PLUGIN_SERVER) return C.int(tsgo.Ts3onClientPokeEvent(uint64(serverConnectionHandlerID), tsgo.AnyId(fromClientID), C.GoString(pokerName), C.GoString(pokerUniqueIdentity), C.GoString(message), int(ffIgnored)))
return 1 }
/*
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)
}
} }