Annotation of /trunk/ModularRex/RexParts/Modules/RexSkypeModule.cs
Parent Directory
|
Revision Log
Revision 144 - (view) (download)
| 1 : | mikkopa | 144 | using System; |
| 2 : | using System.Collections.Generic; | ||
| 3 : | using System.Text; | ||
| 4 : | using OpenSim.Region.Framework.Scenes; | ||
| 5 : | using ModularRex.RexNetwork; | ||
| 6 : | using OpenSim.Framework; | ||
| 7 : | using OpenMetaverse; | ||
| 8 : | using OpenSim.Region.Framework.Interfaces; | ||
| 9 : | using log4net; | ||
| 10 : | using System.Reflection; | ||
| 11 : | |||
| 12 : | namespace ModularRex.RexParts.Modules | ||
| 13 : | { | ||
| 14 : | public class RexSkypeModule : IRegionModule | ||
| 15 : | { | ||
| 16 : | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
| 17 : | |||
| 18 : | private Scene m_scene; | ||
| 19 : | |||
| 20 : | #region IRegionModule Members | ||
| 21 : | |||
| 22 : | public void Close() | ||
| 23 : | { | ||
| 24 : | } | ||
| 25 : | |||
| 26 : | public void Initialise(Scene scene, Nini.Config.IConfigSource source) | ||
| 27 : | { | ||
| 28 : | m_scene = scene; | ||
| 29 : | } | ||
| 30 : | |||
| 31 : | public bool IsSharedModule | ||
| 32 : | { | ||
| 33 : | get { return false; } | ||
| 34 : | } | ||
| 35 : | |||
| 36 : | public string Name | ||
| 37 : | { | ||
| 38 : | get { return "RexSkypeModule"; } | ||
| 39 : | } | ||
| 40 : | |||
| 41 : | public void PostInitialise() | ||
| 42 : | { | ||
| 43 : | m_scene.EventManager.OnNewClient += EventManager_OnNewClient; | ||
| 44 : | } | ||
| 45 : | |||
| 46 : | #endregion | ||
| 47 : | |||
| 48 : | #region Event Handlers | ||
| 49 : | |||
| 50 : | private void EventManager_OnNewClient(IClientAPI client) | ||
| 51 : | { | ||
| 52 : | if (client is RexClientView) | ||
| 53 : | { | ||
| 54 : | RexClientView remoteClient = (RexClientView)client; | ||
| 55 : | |||
| 56 : | //Subscribe to event to get notified when the users skypeurl changes | ||
| 57 : | remoteClient.OnReceiveRexSkypeStore += RexSkypeModule_OnReceiveRexSkypeStore; | ||
| 58 : | |||
| 59 : | //Send all other users skypeaddress to this user | ||
| 60 : | SendAllOtherSkypeAddressesToClient(remoteClient); | ||
| 61 : | } | ||
| 62 : | } | ||
| 63 : | |||
| 64 : | /// <summary> | ||
| 65 : | /// Skype url changed. Send the changed skypeurl to other users | ||
| 66 : | /// </summary> | ||
| 67 : | /// <param name="remoteClient"></param> | ||
| 68 : | private void RexSkypeModule_OnReceiveRexSkypeStore(RexClientView remoteClient) | ||
| 69 : | { | ||
| 70 : | try | ||
| 71 : | { | ||
| 72 : | SendSkypeToAllClients(remoteClient.RexSkypeURL, remoteClient.AgentId); | ||
| 73 : | } | ||
| 74 : | catch (Exception ex) | ||
| 75 : | { | ||
| 76 : | m_log.Error("[REXSKYPE]: ProcessRexSkypeStore threw an exception: " + ex.ToString()); | ||
| 77 : | } | ||
| 78 : | } | ||
| 79 : | |||
| 80 : | #endregion | ||
| 81 : | |||
| 82 : | /// <summary> | ||
| 83 : | /// Send skype address to all users | ||
| 84 : | /// </summary> | ||
| 85 : | /// <param name="skypeAddr">New skype address</param> | ||
| 86 : | /// <param name="agentID">User to whom the skype address belongs to</param> | ||
| 87 : | public void SendSkypeToAllClients(string skypeAddr, UUID agentID) | ||
| 88 : | { | ||
| 89 : | foreach (ScenePresence sp in m_scene.GetScenePresences()) | ||
| 90 : | { | ||
| 91 : | if (sp.ControllingClient is RexClientView) | ||
| 92 : | { | ||
| 93 : | ((RexClientView)sp.ControllingClient).SendSkypeAddress(agentID, skypeAddr); | ||
| 94 : | } | ||
| 95 : | } | ||
| 96 : | } | ||
| 97 : | |||
| 98 : | /// <summary> | ||
| 99 : | /// Send all skype addresses to this client | ||
| 100 : | /// </summary> | ||
| 101 : | /// <param name="remoteClient">Client to send to</param> | ||
| 102 : | public void SendAllOtherSkypeAddressesToClient(RexClientView remoteClient) | ||
| 103 : | { | ||
| 104 : | foreach (ScenePresence sp in m_scene.GetScenePresences()) | ||
| 105 : | { | ||
| 106 : | if (sp.ControllingClient is RexClientView) | ||
| 107 : | { | ||
| 108 : | RexClientView client = ((RexClientView)sp.ControllingClient); | ||
| 109 : | if (client.RexSkypeURL != null && client.RexSkypeURL != string.Empty) | ||
| 110 : | { | ||
| 111 : | remoteClient.SendSkypeAddress(client.AgentId, client.RexSkypeURL); | ||
| 112 : | } | ||
| 113 : | } | ||
| 114 : | } | ||
| 115 : | } | ||
| 116 : | } | ||
| 117 : | } |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |

