private void OnResourceStart() { // Create a JustAnotherVoiceServer based GtmpVoice Server! var hostname = API.getResourceSetting <string>("justanothervoicechat", "voice_host"); var port = API.getResourceSetting <ushort>("justanothervoicechat", "voice_port"); var teamspeakServerId = API.getResourceSetting <string>("justanothervoicechat", "voice_teamspeak_serverid"); var teamspeakChannelId = API.getResourceSetting <ulong>("justanothervoicechat", "voice_teamspeak_channelid"); var teamspeakChannelPassword = API.getResourceSetting <string>("justanothervoicechat", "voice_teamspeak_channelpassword"); _voiceServer = GtmpVoice.CreateServer(API, new VoiceServerConfiguration(hostname, port, teamspeakServerId, teamspeakChannelId, teamspeakChannelPassword)); // Enables 3D Voice _voiceServer.AddTask(new GtmpPositionalTask()); // Attach to some IVoiceServer events to react to certain them with certain actions. AttachToVoiceServerEvents(); // Attach to GTMP-Events, so the connection works and camera rotation updates. AttachToGtmpEvents(true); _radioHandler = new RadioHandler(); _phoneHandler = new TelephoneHandler(_voiceServer); // Startup VoiceServer, so players are able to connect. _voiceServer.Start(); }
private void OnResourceStop() { API.onResourceStop -= OnResourceStop; API.onResourceStart -= OnResourceStart; _radioHandler = null; _phoneHandler = null; _voiceServer.Stop(); _voiceServer.Dispose(); }