Exemplo n.º 1
0
        internal static async System.Threading.Tasks.Task <int> InitAsync()
#endif
        {
            Log("Initializing {0}", PluginVersion);

            Connections        = new ConcurrentDictionary <ulong, Connection>();
            _pluginReturnCodes = new Dictionary <PluginReturnCode, string>();

            foreach (PluginReturnCode code in Enum.GetValues(typeof(PluginReturnCode)))
            {
                var sb = new StringBuilder(255);
                Functions.createReturnCode(PluginID, sb, 255);
                _pluginReturnCodes[code] = sb.ToString();
                Log("{0} => {1}", code, sb.ToString());
            }
#if false
            HttpClient client = new HttpClient();
            client.Timeout = TimeSpan.FromSeconds(2);
            try
            {
                string v = await client.GetStringAsync(VersionCheckUrl);

                if (!String.IsNullOrEmpty(v))
                {
                    if (Version.TryParse(v, out var reqVersion))
                    {
                        if (reqVersion > PluginVersion)
                        {
                            MessageBox.Show($"{Name} veraltet. Version {reqVersion} wird benötigt. Bitte aktualisieren.", "GT-MP Voice Plugin Fehler");
                            return(-1);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log("Could not check version: {0}", ex.Message);
            }
#endif
            IntPtr serverList = IntPtr.Zero;
            if (Functions.getServerConnectionHandlerList(ref serverList) == 0)
            {
                var servers = TeamSpeakBase.ReadLongIDList(serverList, GetConnection);
                Log("{0} already connected Servers", servers.Count);
                servers.Where(c => c.ID != 0).ForEach(c => OnConnectionStatusChanged(c.ID, ConnectionStatusEnum.STATUS_CONNECTION_ESTABLISHED, 0));
            }
            voiceClient = new VoiceClient.VoiceClient();
            voiceClient.OnDisconnected += VoiceClient_OnDisconnected;
            voiceClient.AcceptConnections();
            return(0);
        }