Exemplo n.º 1
0
        internal void Init()
        {
            try
            {
                if (!IsInitialized && Status == ConnectionStatusEnum.STATUS_CONNECTION_ESTABLISHED)
                {
                    Log("INIT");
                    Functions.getClientID(ID, ref LocalClientId);
                    var localClient = GetClient(LocalClientId);
                    localClient.IsLocalClient = true;
                    localClient.Update();
                    LocalClient     = localClient;
                    LocalClientName = localClient.Name;
                    Log("Local client id {0}", LocalClientId);

                    IntPtr retVal = IntPtr.Zero;
                    Functions.getClientList(ID, ref retVal);
                    var newClients = TeamSpeakBase.ReadShortIDList <Client>(retVal, GetClient);
                    Log($"{newClients.Count} Clients");
                    newClients.ForEach(cl => cl.Update());
                    var cu = newClients.Select(cl => cl.ID).ToArray();
                    Log($"{cu.Length} Unmute Clients");
                    DoUnmuteList(cu);
                    LocalClient.UpdateChannel();
                    Functions.systemset3DListenerAttributes(ID, new TSVector(), new TSVector(), new TSVector());
                    IsInitialized = true;
                    Log("ENDINIT");
                }
            }
            catch (Exception ex)
            {
                Log(ex.ToString());
            }
        }
Exemplo n.º 2
0
        internal void Init()
        {
            if (!IsInitialized)
            {
                Functions.getClientID(ID, ref LocalClientId);
                var localClient = GetClient(LocalClientId);
                localClient.IsLocalClient = true;
                localClient.Update();
                LocalClient     = localClient;
                LocalClientName = localClient.Name;
                Log("Local client id {0}", LocalClientId);

                IntPtr retVal = IntPtr.Zero;
                Functions.getClientList(ID, ref retVal);
                var newClients = TeamSpeakBase.ReadShortIDList <Client>(retVal, GetClient);
                Log($"{newClients.Count} Clients");
                newClients.ForEach(cl => cl.Update());
                var cu = newClients.Select(cl => cl.ID).ToArray();
                Log($"{cu.Length} Unmute Clients");
                DoUnmuteList(cu);
                LocalClient.UpdateChannel();
                Functions.systemset3DListenerAttributes(ID, new TSVector(), new TSVector(), new TSVector());
                IsInitialized = true;
            }
        }
Exemplo n.º 3
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);
        }