From 9d2ed9307cacc7ee2b05458afe89c7d93a9aa3cb Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Tue, 26 Feb 2008 10:58:24 +0000 Subject: * Converted VoiceChatServer into a shared region module - now only one instance is required for the entire simulator, rather than one per region. --- .../Modules/VoiceChat/VoiceChatServer.cs | 30 ++++++++++++++++------ 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/Environment/Modules') diff --git a/OpenSim/Region/Environment/Modules/VoiceChat/VoiceChatServer.cs b/OpenSim/Region/Environment/Modules/VoiceChat/VoiceChatServer.cs index 1ac2d33..32aa96e 100644 --- a/OpenSim/Region/Environment/Modules/VoiceChat/VoiceChatServer.cs +++ b/OpenSim/Region/Environment/Modules/VoiceChat/VoiceChatServer.cs @@ -21,7 +21,7 @@ namespace OpenSim.Region.Environment.Modules.VoiceChat Thread m_listenerThread; Thread m_mainThread; - Scene m_scene; + List m_scenes; Socket m_server; Socket m_selectCancel; bool m_enabled = false; @@ -34,7 +34,11 @@ namespace OpenSim.Region.Environment.Modules.VoiceChat public void Initialise(Scene scene, Nini.Config.IConfigSource source) { - m_scene = scene; + if (!m_scenes.Contains(scene)) + m_scenes.Add(scene); + + scene.EventManager.OnNewClient += NewClient; + scene.EventManager.OnRemovePresence += RemovePresence; try { @@ -52,14 +56,11 @@ namespace OpenSim.Region.Environment.Modules.VoiceChat m_clients = new Dictionary(); m_uuidToClient = new Dictionary(); - m_scene.EventManager.OnNewClient += NewClient; - m_scene.EventManager.OnRemovePresence += RemovePresence; - try { CreateListeningSocket(); } - catch (Exception e) + catch (Exception) { m_log.Error("[VOICECHAT]: Unable to start listening"); return; @@ -305,9 +306,22 @@ namespace OpenSim.Region.Environment.Modules.VoiceChat } } + public ScenePresence getScenePresence(LLUUID clientID) + { + foreach (Scene scene in m_scenes) + { + ScenePresence x; + if ((x = scene.GetScenePresence(clientID)) != null) + { + return x; + } + } + return null; + } + public void BroadcastVoice(VoicePacket packet) { - libsecondlife.LLVector3 origPos = m_scene.GetScenePresence(packet.m_clientId).AbsolutePosition; + libsecondlife.LLVector3 origPos = getScenePresence(packet.m_clientId).AbsolutePosition; byte[] bytes = packet.GetBytes(); foreach (VoiceClient client in m_clients.Values) @@ -315,7 +329,7 @@ namespace OpenSim.Region.Environment.Modules.VoiceChat if (client.IsEnabled() && client.m_clientId != packet.m_clientId && client.m_authenticated && client.IsCodecSupported(packet.m_codec)) { - ScenePresence presence = m_scene.GetScenePresence(client.m_clientId); + ScenePresence presence = getScenePresence(client.m_clientId); if (presence != null && Util.GetDistanceTo(presence.AbsolutePosition, origPos) < 20) { -- cgit v1.1