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(); } }
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); } }
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()); } }
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()); } }
void onVoiceConfigureClient(VoicePaketConfigureClient args, NetPeer peer) { var con = VoicePlugin.GetConnection(_connectionInfo.ServerGUID); if (con != null) { con.SetCanLeaveIngameChannel(args.CanLeaveIngameChannel); con.ConnectVoiceServer(args.Nickname); } }
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); }
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); } }
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); }
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); } }
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); } }
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); } }
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); } }
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()); } }
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()); } }
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()); } }
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()); } }
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()); } }
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; }
public static void ts3plugin_onTalkStatusChangeEvent(ulong serverConnectionHandlerID, int status, int isReceivedWhisper, ushort clientID) { // GTMPVoicePlugin.VerboseLog(MethodInfo.GetCurrentMethod().Name); VoicePlugin.GetConnection(serverConnectionHandlerID).ClientTalkStatusChanged(clientID, status, isReceivedWhisper); }
public static void ts3plugin_onClientDisplayNameChanged(ulong serverConnectionHandlerID, ushort clientID, string displayName, string uniqueClientIdentifier) { VoicePlugin.VerboseLog(MethodInfo.GetCurrentMethod().Name); VoicePlugin.GetConnection(serverConnectionHandlerID).GetClient(clientID).SetName(displayName); }
private static void ProcessRequest(IAsyncResult ar) { var ctx = _listener.EndGetContext(ar); _listener.BeginGetContext(ProcessRequest, null); try { var request = ctx.Request; VoicePaketConfig cfg = new VoicePaketConfig(); foreach (var item in ctx.Request.QueryString.AllKeys) { var val = ctx.Request.QueryString[item]; switch (item.ToUpperInvariant()) { case "SERVER": cfg.ServerIP = val; break; case "PORT": if (!int.TryParse(val, out var tInt)) { return; } cfg.ServerPort = tInt; break; case "SECRET": cfg.ServerSecret = val; break; case "CLIENTGUID": cfg.ClientGUID = val; break; case "VERSION": cfg._ClientVersionRequired = val; if (Version.TryParse(val, out var v)) { cfg.ClientVersionRequired = v; } break; } } var replyText = "OK"; switch (ctx.Request.Url.LocalPath) { case "/CONNECT": ConnectionRequestReceived?.Invoke(null, cfg); break; case "/IDENTIFY": { var c = VoicePlugin.GetConnection(cfg.ServerSecret); if (c == null) { break; } replyText = "OK<script>alt.emit(\"j_PureVoiceConnect\",\"" + c.LocalClient.GUID + "\",\"" + VoicePlugin.PluginVersion + "\");</script>"; break; } } var buf = Encoding.UTF8.GetBytes(replyText); ctx.Response.ContentEncoding = Encoding.UTF8; ctx.Response.ContentType = "text/html"; ctx.Response.ContentEncoding = Encoding.UTF8; ctx.Response.AddHeader("Access-Control-Allow-Origin", "*"); ctx.Response.ContentLength64 = buf.Length; ctx.Response.OutputStream.Write(buf, 0, buf.Length); ctx.Response.Close(); return; } catch (Exception ex) { VoicePlugin.Log(ex.ToString()); } }