public IntPtr callInfoData(ulong serverConnectionHandlerID, ulong id, PluginItemType type ) { string data = null; if (infoData != null) infoData(serverConnectionHandlerID, id, type, ref data); return data.UTF8();//Allocates unmanaged memory, TS3 will call ts3plugin_freeMemory which assumes the plugin only uses HGlobal }
public static void ts3plugin_infoData(ulong serverConnectionHandlerID, ulong id, PluginItemType type, [MarshalAs(UnmanagedType.LPStr)] ref string data) { switch (type) { case PluginItemType.PLUGIN_CHANNEL: if (TSPlugin.Instance.ConnectionHandler == null) { return; } string description; TSPlugin.Instance.Functions.getChannelVariableAsString(serverConnectionHandlerID, id, ChannelProperties.CHANNEL_DESCRIPTION, out description); var channelid = Helpers.ExtractChannelID(description); var users = TSPlugin.Instance.ConnectionHandler.GetUsersInChannel(channelid); data = Helpers.UserListToTs3String(users); break; case PluginItemType.PLUGIN_CLIENT: break; case PluginItemType.PLUGIN_SERVER: break; default: Console.WriteLine("Invalid item type: %d\n", type); data = null; /* Ignore */ return; } }