private void API_onResourceStart() { VoiceDefaultChannel = GetVoiceSetting <ulong>("voice_defaultchannel", true); VoiceIngameChannel = GetVoiceSetting <ulong>("voice_ingamechannel", true); VoiceIngameChannelPassword = GetVoiceSetting <string>("voice_ingamechannelpassword", false); VoiceServerGUID = GetVoiceSetting <string>("voice_serverguid", true); VoiceServerIP = GetVoiceSetting <string>("voice_server", true); VoiceServerPort = GetVoiceSetting <int>("voice_port", true); VoiceServerSecret = GetVoiceSetting <string>("voice_secret", true); VoiceClientPort = GetVoiceSetting <int>("voice_clientport", true); Version.TryParse(GetVoiceSetting <string>("voice_minpluginversion", false), out VoiceServerPluginVersion); VoiceEnableLipSync = GetVoiceSetting <bool>("voice_enablelipsync", false, true); VoiceMaxRange = GetVoiceSetting <float>("voice_maxrange", false, 50.0f); VoiceForceVoice = GetVoiceSetting <bool>("voice_forcevoice", false, true); _voiceServer = new PureVoice.Server.VoiceServer(VoiceServerPort, VoiceServerSecret, VoiceServerGUID, VoiceServerPluginVersion, VoiceDefaultChannel, VoiceIngameChannel, VoiceIngameChannelPassword, VoiceEnableLipSync); _voiceServer.VoiceClientConnected += _voiceServer_VoiceClientConnected; _voiceServer.VoiceClientDisconnected += _voiceServer_VoiceClientDisconnected; _voiceServer.VoiceClientOutdated += _voiceServer_VoiceClientOutdated; _voiceServer.VoiceClientTalking += _voiceServer_VoiceClientTalking; _voiceServer.VoiceClientMicrophoneStatusChanged += _voiceServer_VoiceClientMicrophoneStatusChanged; _voiceServer.VoiceClientSpeakersStatusChanged += _voiceServer_VoiceClientSpeakersStatusChanged; teamspeakTimer = API.delay(200, false, () => UpdateTeamspeak()); API.onPlayerDeath += API_onPlayerDeath; API.onPlayerFinishedDownload += API_onPlayerFinishedDownload; API.onPlayerDisconnected += API_onPlayerDisconnected; }
private void World_OnWorldStartup() { _voiceServer = new PureVoice.Server.VoiceServer(GameMode.VoiceServerPort, GameMode.VoiceServerSecret, GameMode.VoiceServerGUID, GameMode.VoiceServerPluginVersion, GameMode.VoiceDefaultChannel, GameMode.VoiceIngameChannel, GameMode.VoiceIngameChannelPassword, GameMode.VoiceEnableLipSync); _voiceServer.VoiceClientConnected += _voiceServer_VoiceClientConnected; _voiceServer.VoiceClientDisconnected += _voiceServer_VoiceClientDisconnected; _voiceServer.VoiceClientOutdated += _voiceServer_VoiceClientOutdated; _voiceServer.VoiceClientTalking += _voiceServer_VoiceClientTalking; _voiceServer.VoiceClientMicrophoneStatusChanged += _voiceServer_VoiceClientMicrophoneStatusChanged; _voiceServer.VoiceClientSpeakersStatusChanged += _voiceServer_VoiceClientSpeakersStatusChanged; teamspeakTimer = API.delay(200, false, () => UpdateTeamspeak()); }
public void StartVoice() { VoiceDefaultChannel = GetVoiceSetting <ulong>("voice_defaultchannel", VoiceDefaultChannel); VoiceIngameChannel = GetVoiceSetting <ulong>("voice_ingamechannel", VoiceIngameChannel); VoiceIngameChannelPassword = GetVoiceSetting <string>("voice_ingamechannelpassword", VoiceIngameChannelPassword); VoiceServerGUID = GetVoiceSetting <string>("voice_serverguid", VoiceServerGUID); VoiceServerIP = GetVoiceSetting <string>("voice_server", VoiceServerIP); VoiceServerPort = GetVoiceSetting <int>("voice_port", VoiceServerPort); VoiceServerSecret = GetVoiceSetting <string>("voice_secret", VoiceServerSecret); VoiceClientPort = GetVoiceSetting <int>("voice_clientport", VoiceClientPort); Version.TryParse(GetVoiceSetting <string>("voice_minpluginversion", VoiceServerPluginVersion.ToString()), out VoiceServerPluginVersion); VoiceEnableLipSync = GetVoiceSetting <bool>("voice_enablelipsync", VoiceEnableLipSync); VoiceMaxRange = GetVoiceSetting <float>("voice_maxrange", VoiceMaxRange); VoiceForceVoice = GetVoiceSetting <bool>("voice_forcevoice", VoiceForceVoice); _voiceServer = new PureVoice.Server.VoiceServer(VoiceServerPort, VoiceServerSecret, VoiceServerGUID, VoiceServerPluginVersion, VoiceDefaultChannel, VoiceIngameChannel, VoiceIngameChannelPassword, VoiceEnableLipSync); _voiceServer.VoiceClientConnected += _voiceServer_VoiceClientConnected; _voiceServer.VoiceClientDisconnected += _voiceServer_VoiceClientDisconnected; _voiceServer.VoiceClientOutdated += _voiceServer_VoiceClientOutdated; _voiceServer.VoiceClientMicrophoneStatusChanged += _voiceServer_VoiceClientMicrophoneStatusChanged; _voiceServer.VoiceClientSpeakersStatusChanged += _voiceServer_VoiceClientSpeakersStatusChanged; if (VoiceEnableLipSync) { _voiceServer.VoiceClientTalking += _voiceServer_VoiceClientTalking; } teamspeakTimer = new System.Timers.Timer(200); teamspeakTimer.AutoReset = true; teamspeakTimer.Elapsed += (sender, args) => { try { UpdateTeamspeak(); } catch (System.Threading.ThreadAbortException) { } catch (Exception ex) { OnVoiceLogging?.Invoke(LogLevel.Error, ex.ToString()); } }; teamspeakTimer.Start(); Alt.OnPlayerDead += Alt_OnPlayerDead; Alt.OnPlayerConnect += Alt_OnPlayerConnect; Alt.OnPlayerDisconnect += Alt_OnPlayerDisconnect; }
static void Main(string[] args) { PureVoice.Server.VoiceServer.SetMinLogLevel(PureVoice.Server.LogLevel.TRACE); _vs = new PureVoice.Server.VoiceServer(1234, "geheim", "GusXJvzOPDkfrtsfCXTsxqAOLfI=", new Version(0, 2, 1265, 371), 2, 15, "123", true); _vs.VoiceClientConnected += _vs_VoiceClientConnected; UdpClient uc = new UdpClient(); EventBasedNetListener clientListener = new EventBasedNetListener(); clientListener.ConnectionRequestEvent += (p) => p.Reject(); var _server = new NetManager(clientListener) { UnsyncedEvents = true, UnconnectedMessagesEnabled = false, DiscoveryEnabled = false }; _server.Start(); while (!Console.KeyAvailable) { NetDataWriter nw = new NetDataWriter(); nw.Put("GTMPVOICE"); nw.Put(1); nw.Put("127.0.0.1"); nw.Put(1234); nw.Put("geheim"); nw.Put("clientGUID"); nw.Put("0.2.1265.371"); while (true) { try { //Logger.Trace("Sending Ping"); _server.SendUnconnectedMessage(nw.Data, new NetEndPoint("127.0.0.1", 4239)); Thread.Sleep(4000); } catch (Exception ex) { return; } } } }