Exemplo n.º 1
0
        void onVoiceMute(VoicePaketMute args, NetPeer peer)
        {
            var con = VoicePlugin.GetConnection(_connectionInfo.ServerGUID);

            if (con == null)
            {
                return;
            }
            if (args.IsMute)
            {
                VoicePlugin.Log("Mute {0}", args.Name);
                if (args.Name == "_ALL_")
                {
                    con.Mute("_ALL_");
                }
                else
                {
                    con.GetClient(args.Name)?.Mute();
                }
            }
            else
            {
                VoicePlugin.Log("Unmute {0}", args.Name);
                con.GetClient(args.Name)?.Unmute();
            }
        }
Exemplo n.º 2
0
 public static int ts3plugin_onServerErrorEvent(ulong serverConnectionHandlerID, string errorMessage, uint error, string returnCode, string extraMessage)
 {
     try
     {
         if (!string.IsNullOrEmpty(returnCode))
         {
             if (error != 0)
             {
                 VoicePlugin.Log("ERROR: {0} ({1} {2} {3})", errorMessage, error, returnCode, extraMessage);
                 var rCode = VoicePlugin.ReturnCodeToPluginReturnCode(returnCode);
                 if (rCode == PluginReturnCode.JOINCHANNEL)
                 {
                     if (error != 770)
                     {
                         VoicePlugin.GetConnection(serverConnectionHandlerID).LocalClient.JoinDefaultChannel();
                     }
                 }
             }
             return(1);
         }
         return(0);
     }
     catch (Exception ex)
     {
         VoicePlugin.Log("Excepion in {0} : {1}", MethodInfo.GetCurrentMethod().Name, ex.Message);
         return(0);
     }
 }
Exemplo n.º 3
0
 void onVoiceSetup(VoicePaketSetup args, NetPeer peer)
 {
     try
     {
         VoicePlugin.Log("VoiceSetup {0}", args);
         _connectionInfo = args;
         var con = VoicePlugin.GetConnection(args.ServerGUID);
         if ((con != null) && con.IsInitialized && con.IsConnected)
         {
             if (!VoicePlugin_ConnectionEstablished(con))
             {
                 VoicePlugin.Log("Disconnecting Peer (TS Server not ready)");
                 Disconnect();
             }
         }
         else
         {
             VoicePlugin.Log("Disconnecting Peer (TS Server not connected)");
             Disconnect();
         }
     }
     catch (Exception ex)
     {
         VoicePlugin.Log(ex.ToString());
     }
 }
Exemplo n.º 4
0
 void onVoiceCommand(VoicePaketCommand args, NetPeer peer)
 {
     try
     {
         VoicePlugin.Log("VoiceCommand {0} => {1}", args.Command, args.Data);
         if (args.Command == "DISCONNECT")
         {
             _needConnection = false;
             var Connection = Client.GetFirstPeer();
             Connection?.Disconnect();
             Connection = null;
             var con = VoicePlugin.GetConnection(_connectionInfo.ServerGUID);
             if (con != null)
             {
                 con.DisconnectVoiceServer();
             }
             OnDisconnected?.Invoke(this, this);
             return;
         }
         if (args.Command == "SETNAME")
         {
             var con = VoicePlugin.GetConnection(_connectionInfo.ServerGUID);
             if (con != null)
             {
                 con.ConnectVoiceServer(args.Data);
             }
         }
     }
     catch (Exception ex)
     {
         VoicePlugin.Log(ex.ToString());
     }
 }
Exemplo n.º 5
0
        public static int ts3plugin_init()
        {
            VoicePlugin.VerboseLog(MethodInfo.GetCurrentMethod().Name);
#if false
            return(VoicePlugin.InitAsync().GetAwaiter().GetResult());
#else
            return(VoicePlugin.InitAsync());
#endif
        }
Exemplo n.º 6
0
        void onVoiceConfigureClient(VoicePaketConfigureClient args, NetPeer peer)
        {
            var con = VoicePlugin.GetConnection(_connectionInfo.ServerGUID);

            if (con != null)
            {
                con.SetCanLeaveIngameChannel(args.CanLeaveIngameChannel);
                con.ConnectVoiceServer(args.Nickname);
            }
        }
Exemplo n.º 7
0
 public void Shutdown()
 {
     _ShutDown = true;
     VoicePlugin.Log("Shutting down voiceClient");
     if (_timer.Enabled)
     {
         _timer.Stop();
     }
     Client?.Stop();
     ServerListener?.Stop();
 }
Exemplo n.º 8
0
        public static void ts3plugin_onClientMoveMovedEvent(ulong serverConnectionHandlerID, ushort clientID, ulong oldChannelID, ulong newChannelID, int visibility, ushort moverID, string moverName, string moverUniqueIdentifier, string moveMessage)
        {
            VoicePlugin.Log("{0} {1}: {2} => {3} v:{4} ", MethodInfo.GetCurrentMethod().Name, clientID, oldChannelID, newChannelID, visibility);
            var cl = VoicePlugin.GetConnection(serverConnectionHandlerID).GetClient(clientID);

            if (oldChannelID == 0) // New User connected
            {
                cl.Update();
            }
            cl.OnChannelChanged(newChannelID);
        }
Exemplo n.º 9
0
 public static void ts3plugin_onClientSelfVariableUpdateEvent(ulong serverConnectionHandlerID, int flag, string oldValue, string newValue)
 {
     try
     {
         VoicePlugin.VerboseLog("{0} {1} o:{2} n:{3}", MethodInfo.GetCurrentMethod().Name, (ClientProperty)flag, oldValue, newValue);
         VoicePlugin.GetConnection(serverConnectionHandlerID).LocalClient?.OnSelfVariableChanged((ClientProperty)flag, oldValue, newValue);
     }
     catch (Exception ex)
     {
         VoicePlugin.Log("Excepion in {0} : {1}", MethodInfo.GetCurrentMethod().Name, ex.Message);
     }
 }
Exemplo n.º 10
0
 public static void ts3plugin_onClientDisplayNameChanged(ulong serverConnectionHandlerID, ushort clientID, string displayName, string uniqueClientIdentifier)
 {
     try
     {
         VoicePlugin.VerboseLog(MethodInfo.GetCurrentMethod().Name);
         VoicePlugin.GetConnection(serverConnectionHandlerID).GetClient(clientID).SetName(displayName);
     }
     catch (Exception ex)
     {
         VoicePlugin.Log("Excepion in {0} : {1}", MethodInfo.GetCurrentMethod().Name, ex.Message);
     }
 }
Exemplo n.º 11
0
 public static void ts3plugin_onTalkStatusChangeEvent(ulong serverConnectionHandlerID, int status, int isReceivedWhisper, ushort clientID)
 {
     try
     {
         // GTMPVoicePlugin.VerboseLog(MethodInfo.GetCurrentMethod().Name);
         VoicePlugin.GetConnection(serverConnectionHandlerID).ClientTalkStatusChanged(clientID, status, isReceivedWhisper);
     }
     catch (Exception ex)
     {
         VoicePlugin.Log("Excepion in {0} : {1}", MethodInfo.GetCurrentMethod().Name, ex.Message);
     }
 }
Exemplo n.º 12
0
 public static void ts3plugin_onConnectStatusChangeEvent(ulong serverConnectionHandlerID, int newStatus, uint errorNumber)
 {
     try
     {
         VoicePlugin.VerboseLog(MethodInfo.GetCurrentMethod().Name);
         VoicePlugin.OnConnectionStatusChanged(serverConnectionHandlerID, (ConnectionStatusEnum)newStatus, errorNumber);
     }
     catch (Exception ex)
     {
         VoicePlugin.Log("Excepion in {0} : {1}", MethodInfo.GetCurrentMethod().Name, ex.Message);
     }
 }
Exemplo n.º 13
0
        public static void ts3plugin_onClientMoveEvent(ulong serverConnectionHandlerID, ushort clientID, ulong oldChannelID, ulong newChannelID, int visibility, string moveMessage)
        {
            VoicePlugin.Log("{0} {1}: {2} => {3} v:{4} ", MethodInfo.GetCurrentMethod().Name, clientID, oldChannelID, newChannelID, visibility);
            if (newChannelID == 0) // Someone Disconnected
            {
                VoicePlugin.GetConnection(serverConnectionHandlerID).RemoveClient(clientID);
                return;
            }
            var cl = VoicePlugin.GetConnection(serverConnectionHandlerID).GetClient(clientID);

            cl.OnChannelChanged(newChannelID);
        }
Exemplo n.º 14
0
 public static void ts3plugin_onUpdateClientEvent(ulong serverConnectionHandlerID, ushort clientID, ushort invokerID, string invokerName, string invokerUniqueIdentifier)
 {
     try
     {
         VoicePlugin.VerboseLog("{0} {1}", MethodInfo.GetCurrentMethod().Name, clientID);
         VoicePlugin.GetConnection(serverConnectionHandlerID)?.GetKnownClient(clientID)?.Update();
     }
     catch (Exception ex)
     {
         VoicePlugin.Log("Excepion in {0} : {1}", MethodInfo.GetCurrentMethod().Name, ex.Message);
     }
 }
Exemplo n.º 15
0
 public static void ts3plugin_onClientMoveTimeoutEvent(ulong serverConnectionHandlerID, ushort clientID, ulong oldChannelID, ulong newChannelID, int visibility, string timeoutMessage)
 {
     try
     {
         VoicePlugin.Log("{0} {1}: {2} => {3} v:{4} ", MethodInfo.GetCurrentMethod().Name, clientID, oldChannelID, newChannelID, visibility);
         VoicePlugin.GetConnection(serverConnectionHandlerID).GetKnownClient(clientID)?.OnChannelChanged(newChannelID);
     }
     catch (Exception ex)
     {
         VoicePlugin.Log("Excepion in {0} : {1}", MethodInfo.GetCurrentMethod().Name, ex.Message);
     }
 }
Exemplo n.º 16
0
 public static void ts3plugin_setFunctionPointers(TS3Functions functionsFromTeamSpeak)
 {
     try
     {
         Debug.WriteLine("SetFunctionPointers");
         VoicePlugin.SetFunctionPointer(functionsFromTeamSpeak);
         TeamSpeakBase.SetFunctionPointer(functionsFromTeamSpeak);
     }
     catch (Exception ex)
     {
         VoicePlugin.Log(ex.ToString());
     }
 }
Exemplo n.º 17
0
 void onVoiceBatchMute(VoicePaketBatchMute data, NetPeer peer)
 {
     try
     {
         VoicePlugin.Log("BatchMute {0}", data.Mutelist.Count);
         var con = VoicePlugin.GetConnection(_connectionInfo.ServerGUID);
         if (con == null)
         {
             return;
         }
         data.Mutelist.ForEach(d => con.GetClient(d)?.Mute());
         con.DoMuteList(data.Mutelist.ToArray());
     }
     catch (Exception ex)
     {
         VoicePlugin.Log(ex.ToString());
     }
 }
Exemplo n.º 18
0
 void onVoiceBatchUpdate(VoicePaketBatchUpdate data, NetPeer peer)
 {
     try
     {
         var con = VoicePlugin.GetConnection(_connectionInfo.ServerGUID);
         if (con == null)
         {
             return;
         }
         var mute = new HashSet <ushort>(con.GetChannel(con.IngameChannel).AllClients);
         mute.Remove(con.LocalClientId);
         var unmute = new HashSet <ushort>();
         if (data.Data.Length > 0)
         {
             data.Data.ForEach(d =>
             {
                 if (d.ClientID == 0)
                 {
                     d.ClientID = con.GetClientId(d.ClientName);
                 }
                 if (d.ClientID != 0)
                 {
                     mute.Remove(d.ClientID);
                     unmute.Add(d.ClientID);
                     con.GetClient(d.ClientID)?.UpdatePosition(d.Position, d.VolumeModifier, false, false);
                 }
             });
         }
         if (mute.SetEquals(con._MutedClients) && unmute.SetEquals(con._UnmutedClients))
         {
             return;
         }
         VoicePlugin.Log("BatchUpdate {0}", data.Data.Length);
         con._UnmutedClients = new ConcurrentHashSet <ushort>(unmute);
         con._MutedClients   = new ConcurrentHashSet <ushort>(mute);
         con._MutedClients.TryRemove(con.LocalClientId);
         con.DoMuteActions();
     }
     catch (Exception ex)
     {
         VoicePlugin.Log(ex.ToString());
     }
 }
Exemplo n.º 19
0
 internal bool VoicePlugin_ConnectionEstablished(Connection e)
 {
     try
     {
         if (_connectionInfo == null)
         {
             VoicePlugin.Log("ConnectionEstablished no info ({0})", e.GUID);
             return(false);
         }
         if (!e.IsInitialized)
         {
             VoicePlugin.Log("ConnectionEstablished not initialized ({0})", e.GUID);
             return(false);
         }
         if (e.GUID == _connectionInfo.ServerGUID)
         {
             if (e.IsVoiceEnabled)
             {
                 VoicePlugin.Log("ConnectionEstablished Gotcha! ({0})", e.GUID);
             }
             e.UpdateSetup(_connectionInfo);
             _netPacketProcessor.Send(Client, new VoicePaketConnectClient()
             {
                 ClientGUID          = _configuration.ClientGUID,
                 TeamspeakID         = e.LocalClient.GUID,
                 TeamspeakClientID   = e.LocalClientId,
                 TeamspeakClientName = e.LocalClient.Name,
                 MicrophoneMuted     = e.LocalClient.IsMicrophoneMuted,
                 SpeakersMuted       = e.LocalClient.IsSpeakersMuted
             }, DeliveryMethod.ReliableOrdered);
         }
         else
         {
             VoicePlugin.Log("ConnectionEstablished wrong server ({0})", e.GUID);
         }
         return(true);
     }
     catch (Exception ex)
     {
         VoicePlugin.Log(ex.ToString());
         return(false);
     }
 }
Exemplo n.º 20
0
        private static void HttpListenerThread()
        {
            _listener = new HttpListener();
            try
            {
                VoicePlugin.Log($"Listening on {url}");

                _listener.Prefixes.Add(url);
                _listener.AuthenticationSchemes = AuthenticationSchemes.Anonymous;
                _listener.Start();
            }
            catch (Exception ex)
            {
                VoicePlugin.Log(ex.ToString());
                return;
            }
            IAsyncResult ar = _listener.BeginGetContext(ProcessRequest, null);

            webStopEvent.WaitOne();
        }
Exemplo n.º 21
0
        private void ClientListener_PeerDisconnectedEvent(NetPeer peer, DisconnectInfo disconnectInfo)
        {
            try
            {
                VoicePlugin.Log("PeerDisconnectedEvent {0} => {1}", peer, disconnectInfo.Reason);

                _needConnection = false;
                var con = VoicePlugin.GetConnection(_connectionInfo.ServerGUID);
                if (con != null)
                {
                    con.DisconnectVoiceServer();
                }
                OnDisconnected?.Invoke(this, this);
                Disconnect();
            }
            catch (Exception ex)
            {
                VoicePlugin.Log(ex.ToString());
            }
        }
Exemplo n.º 22
0
 private void ClientListener_NetworkLatencyUpdateEvent(NetPeer peer, int latency)
 {
     try
     {
         if (_needConnection && (DateTime.Now - _lastPureVoicePing > TimeSpan.FromSeconds(10)))
         {
             _needConnection = false;
             var con = VoicePlugin.GetConnection(_connectionInfo.ServerGUID);
             if (con != null)
             {
                 con.DisconnectVoiceServer();
             }
             OnDisconnected?.Invoke(this, this);
             Disconnect();
         }
     }
     catch (Exception ex)
     {
         VoicePlugin.Log(ex.ToString());
     }
 }
Exemplo n.º 23
0
 void onVoiceUpdate(VoicePaketUpdate args, NetPeer peer)
 {
     try
     {
         var con = VoicePlugin.GetConnection(_connectionInfo.ServerGUID);
         if (con == null)
         {
             return;
         }
         Client cl = con.GetClient(args.PlayerName);
         if (cl == null)
         {
             VoicePlugin.Log("UpdatePosition {0}: {1} {2} {3} NOT FOUND", args.PlayerName, args.Position, args.PositionIsRelative, args.VolumeModifier);
             return;
         }
         cl.UpdatePosition(args.Position, args.VolumeModifier, args.PositionIsRelative);
     }
     catch (Exception ex)
     {
         VoicePlugin.Log(ex.ToString());
     }
 }
Exemplo n.º 24
0
        public MainWindow()
        {
            InitializeComponent();

            VoicePluginData.Current.ActiveVoiceScenariosIds = new string[] { "1", "2", "3" };
            VoicePluginData.Current.WithoutActivationVoiceScenariosIds = new string[] { "2" };
            VoicePluginData.Current.CommandsViewScenarioId = "4";
            VoicePluginData.Current.VolumeLevelScenarioId = "1";

            var scenarios = new ScenarioCast[] {
                new ScenarioCastTest(new FloatValueType(){ AcceptedValues=new string[]{"0", "100" } }, "Звук", "1"),
                new ScenarioCastTest(new InfoValueType(), "Вывод", "4"),
                new ScenarioCastTest(new ButtonValueType(), "Тест", "2"),
                new ScenarioCastTest(new InfoValueType(), "сообщение наде", "3"),
            };

            var voicePlugin = new VoicePlugin();
            voicePlugin.SetCasts(() => scenarios);
            voicePlugin.Initialize();
            voicePlugin.SetValue(null, ToggleValueType.ValueON);

            voicePlugin.UserInitializeWith(null, false);
        }
Exemplo n.º 25
0
        private void WebListener_ConnectionRequestReceived(object sender, VoicePaketConfig e)
        {
            try
            {
                if (_ShutDown)
                {
                    return;
                }
                _lastPureVoicePing = DateTime.Now;

                VoicePlugin.Log("Accept Configuration via Web");
                if (IsConnected)
                {
                    VoicePlugin.Log("Already connected");
                    return;
                }

                if (e.ClientVersionRequired > VoicePlugin.PluginVersion)
                {
                    if (!_GotWarning)
                    {
                        _GotWarning = true;
                        MessageBox.Show($"{VoicePlugin.Name} outdated. Version {e.ClientVersionRequired} is required. Please update.", "PureVoice Plugin Outdated");
                    }
                    return;
                }
                _lastPureVoicePing = DateTime.Now;
                //VoicePlugin.Log("process VoicePaketConfig {0}", _configuration);
                _configuration  = e;
                _needConnection = true;
                // StartServerConnection();
            }
            catch (Exception ex)
            {
                VoicePlugin.Log(ex.ToString());
            }
        }
Exemplo n.º 26
0
        public void AcceptConnections()
        {
            NetDebug.Logger = this;

            _netPacketProcessor.SubscribeNetSerializable <VoicePaketSetup, NetPeer>(onVoiceSetup);
            _netPacketProcessor.SubscribeNetSerializable <VoicePaketCommand, NetPeer>(onVoiceCommand);
            _netPacketProcessor.SubscribeNetSerializable <VoicePaketUpdate, NetPeer>(onVoiceUpdate);
            _netPacketProcessor.SubscribeNetSerializable <VoicePaketMute, NetPeer>(onVoiceMute);
            _netPacketProcessor.SubscribeNetSerializable <VoicePaketBatchMute, NetPeer>(onVoiceBatchMute);
            _netPacketProcessor.SubscribeNetSerializable <VoicePaketBatchUpdate, NetPeer>(onVoiceBatchUpdate);
            _netPacketProcessor.SubscribeNetSerializable <VoicePaketConfigureClient, NetPeer>(onVoiceConfigureClient);

            clientListener.NetworkReceiveEvent +=
                (peer, reader, method) =>
            {
                _netPacketProcessor.ReadAllPackets(reader, peer);
            };
            clientListener.PeerConnectedEvent        += (p) => VoicePlugin.Log("PeerConnectedEvent {0}", p);
            clientListener.PeerDisconnectedEvent     += ClientListener_PeerDisconnectedEvent;
            clientListener.NetworkErrorEvent         += (p, e) => VoicePlugin.Log("NetworkErrorEvent {0} => {1}", p, e);
            clientListener.NetworkLatencyUpdateEvent += ClientListener_NetworkLatencyUpdateEvent;

            _timer          = new System.Timers.Timer();
            _timer.Interval = 100;
            _timer.Elapsed += (s, e) =>
            {
                if (_needConnection)
                {
                    if (IsConnected && DateTime.Now - _lastPureVoicePing > TimeSpan.FromSeconds(10))
                    {
                        _needConnection = false;
                        var con = VoicePlugin.GetConnection(_connectionInfo.ServerGUID);
                        if (con != null)
                        {
                            con.DisconnectVoiceServer();
                        }
                        OnDisconnected?.Invoke(this, this);
                        Disconnect();
                        return;
                    }

                    if (!IsConnected)
                    {
                        StartServerConnection();
                        return;
                    }
                }
                if (IsConnected)
                {
                    Client?.PollEvents();
                }
            };

            if (!_timer.Enabled)
            {
                _timer.Start();
            }

            var evL = new EventBasedNetListener();

            evL.NetworkReceiveUnconnectedEvent += (ep, reader, messageType) => ServerListener_NetworkReceiveUnconnectedEvent(ep, reader, messageType);
            ServerListener = new NetManager(evL)
            {
                UnconnectedMessagesEnabled = true, UnsyncedEvents = true
            };
            ServerListener.Start(4239);
            WebListener.ConnectionRequestReceived += WebListener_ConnectionRequestReceived;
            WebListener.StartListen();
            VoicePlugin.Log("voiceClient waiting for Connectioninfo...");
            _ShutDown = false;
        }
Exemplo n.º 27
0
 public void WriteNet(ConsoleColor color, string str, params object[] args)
 {
     VoicePlugin.Log(str, args);
 }
Exemplo n.º 28
0
        private void ServerListener_NetworkReceiveUnconnectedEvent(NetEndPoint remoteEndPoint, NetDataReader reader, UnconnectedMessageType messageType)
        {
            try
            {
                if (_ShutDown)
                {
                    return;
                }
                if ((remoteEndPoint.Host != "127.0.0.1") && (remoteEndPoint.Host != "[::1]"))
                {
                    VoicePlugin.Log("Refused from {0}", remoteEndPoint);
                    return;
                }
                if (messageType != UnconnectedMessageType.BasicMessage)
                {
                    VoicePlugin.Log("Refused {1} from {0}", remoteEndPoint, messageType);
                    return;
                }

                var hello        = reader.GetString();
                var voiceVersion = reader.GetInt();
                if (voiceVersion != 1)
                {
                    VoicePlugin.Log("Refused v {1} from {0}", remoteEndPoint, voiceVersion);
                    return;
                }
                if ((hello == "GTMPVOICECOMMAND") || (hello == "PUREVOICECOMMAND"))
                {
                    VoicePlugin.Log("Command from {0}", remoteEndPoint);
                    if (IsConnected)
                    {
                        var Connection = Client?.GetFirstPeer();
                        if ((Connection != null) && (Connection.ConnectionState == ConnectionState.Connected))
                        {
                            _netPacketProcessor.Send(Connection, new VoicePaketCommand()
                            {
                                Command = reader.GetString(), Data = reader.GetString()
                            }, DeliveryMethod.ReliableOrdered);
                        }
                    }
                    return;
                }
                if ((hello != "GTMPVOICE") && (hello != "PUREVOICE"))
                {
                    VoicePlugin.Log("Invalid configuration from {0}", remoteEndPoint);
                    return;
                }
                _configuration = new VoicePaketConfig();
                _configuration.Deserialize(reader);

                _lastPureVoicePing = DateTime.Now;

                VoicePlugin.Log("Accept Configuration from {0}", remoteEndPoint);
                if (IsConnected)
                {
                    VoicePlugin.Log("Already connected");
                    return;
                }

                if (_configuration.ClientVersionRequired > VoicePlugin.PluginVersion)
                {
                    if (!_GotWarning)
                    {
                        _GotWarning = true;
                        MessageBox.Show($"{VoicePlugin.Name} outdated. Version {_configuration.ClientVersionRequired} is required. Please update.", "PureVoice Plugin Outdated");
                    }
                    return;
                }
                _lastPureVoicePing = DateTime.Now;
                //VoicePlugin.Log("process VoicePaketConfig {0}", _configuration);
                _needConnection = true;
                StartServerConnection();
            }
            catch (Exception ex)
            {
                VoicePlugin.Log("Invalid Serverpaket from {0}: {1}", remoteEndPoint, ex.Message);
            }
        }
Exemplo n.º 29
0
 public static String ts3plugin_description()
 {
     VoicePlugin.VerboseLog(MethodInfo.GetCurrentMethod().Name);
     return(VoicePlugin.Description);
 }
Exemplo n.º 30
0
 private void ClientListener_ConnectionRequestEvent(ConnectionRequest request)
 {
     VoicePlugin.Log("conrequest ");
 }