aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs
diff options
context:
space:
mode:
authorMelanie2010-05-05 22:50:11 +0100
committerMelanie2010-05-05 22:50:11 +0100
commit7e0d5b866519a303490ee4c30b33c7598d99bbb1 (patch)
treeebe6627b312fb98e813ecc0d4adb98bf4fb36334 /OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs
parentPlumb Viewer version into ScenePresence for initial login. It's still not (diff)
parentStab a test fail (diff)
downloadopensim-SC-7e0d5b866519a303490ee4c30b33c7598d99bbb1.zip
opensim-SC-7e0d5b866519a303490ee4c30b33c7598d99bbb1.tar.gz
opensim-SC-7e0d5b866519a303490ee4c30b33c7598d99bbb1.tar.bz2
opensim-SC-7e0d5b866519a303490ee4c30b33c7598d99bbb1.tar.xz
Merge branch 'master' into careminster-presence-refactor
Diffstat (limited to 'OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs')
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs217
1 files changed, 50 insertions, 167 deletions
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs
index 79b9a16..ab343c8 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs
@@ -29,7 +29,6 @@ using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Reflection; 31using System.Reflection;
32using System.Text;
33 32
34using Nwc.XmlRpc; 33using Nwc.XmlRpc;
35 34
@@ -62,7 +61,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
62 61
63 private bool m_connectorEnabled = false; 62 private bool m_connectorEnabled = false;
64 63
65 private string m_groupsServerURI = string.Empty; 64 private string m_serviceURL = string.Empty;
66 65
67 private bool m_disableKeepAlive = false; 66 private bool m_disableKeepAlive = false;
68 67
@@ -70,17 +69,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
70 private string m_groupWriteKey = string.Empty; 69 private string m_groupWriteKey = string.Empty;
71 70
72 private IUserAccountService m_accountService = null; 71 private IUserAccountService m_accountService = null;
73 72
74 private ExpiringCache<string, XmlRpcResponse> m_memoryCache;
75 private int m_cacheTimeout = 30;
76
77 // Used to track which agents are have dropped from a group chat session
78 // Should be reset per agent, on logon
79 // TODO: move this to Flotsam XmlRpc Service
80 // SessionID, List<AgentID>
81 private Dictionary<UUID, List<UUID>> m_groupsAgentsDroppedFromChatSession = new Dictionary<UUID, List<UUID>>();
82 private Dictionary<UUID, List<UUID>> m_groupsAgentsInvitedToChatSession = new Dictionary<UUID, List<UUID>>();
83
84 73
85 #region IRegionModuleBase Members 74 #region IRegionModuleBase Members
86 75
@@ -115,13 +104,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
115 return; 104 return;
116 } 105 }
117 106
118 m_log.InfoFormat("[XMLRPC-GROUPS-CONNECTOR]: Initializing {0}", this.Name); 107 m_log.InfoFormat("[GROUPS-CONNECTOR]: Initializing {0}", this.Name);
119 108
120 m_groupsServerURI = groupsConfig.GetString("GroupsServerURI", string.Empty); 109 m_serviceURL = groupsConfig.GetString("XmlRpcServiceURL", string.Empty);
121 if ((m_groupsServerURI == null) || 110 if ((m_serviceURL == null) ||
122 (m_groupsServerURI == string.Empty)) 111 (m_serviceURL == string.Empty))
123 { 112 {
124 m_log.ErrorFormat("Please specify a valid URL for GroupsServerURI in OpenSim.ini, [Groups]"); 113 m_log.ErrorFormat("Please specify a valid URL for XmlRpcServiceURL in OpenSim.ini, [Groups]");
125 m_connectorEnabled = false; 114 m_connectorEnabled = false;
126 return; 115 return;
127 } 116 }
@@ -131,26 +120,17 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
131 m_groupReadKey = groupsConfig.GetString("XmlRpcServiceReadKey", string.Empty); 120 m_groupReadKey = groupsConfig.GetString("XmlRpcServiceReadKey", string.Empty);
132 m_groupWriteKey = groupsConfig.GetString("XmlRpcServiceWriteKey", string.Empty); 121 m_groupWriteKey = groupsConfig.GetString("XmlRpcServiceWriteKey", string.Empty);
133 122
123
134 124
135 m_cacheTimeout = groupsConfig.GetInt("GroupsCacheTimeout", 30);
136 if (m_cacheTimeout == 0)
137 {
138 m_log.WarnFormat("[XMLRPC-GROUPS-CONNECTOR]: Groups Cache Disabled.");
139 }
140 else
141 {
142 m_log.InfoFormat("[XMLRPC-GROUPS-CONNECTOR]: Groups Cache Timeout set to {0}.", m_cacheTimeout);
143 }
144 125
145 // If we got all the config options we need, lets start'er'up 126 // If we got all the config options we need, lets start'er'up
146 m_memoryCache = new ExpiringCache<string, XmlRpcResponse>();
147 m_connectorEnabled = true; 127 m_connectorEnabled = true;
148 } 128 }
149 } 129 }
150 130
151 public void Close() 131 public void Close()
152 { 132 {
153 m_log.InfoFormat("[XMLRPC-GROUPS-CONNECTOR]: Closing {0}", this.Name); 133 m_log.InfoFormat("[GROUPS-CONNECTOR]: Closing {0}", this.Name);
154 } 134 }
155 135
156 public void AddRegion(OpenSim.Region.Framework.Scenes.Scene scene) 136 public void AddRegion(OpenSim.Region.Framework.Scenes.Scene scene)
@@ -776,69 +756,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
776 756
777 XmlRpcCall(requestingAgentID, "groups.addGroupNotice", param); 757 XmlRpcCall(requestingAgentID, "groups.addGroupNotice", param);
778 } 758 }
779
780
781
782 #endregion
783
784 #region GroupSessionTracking
785
786 public void ResetAgentGroupChatSessions(UUID agentID)
787 {
788 foreach (List<UUID> agentList in m_groupsAgentsDroppedFromChatSession.Values)
789 {
790 agentList.Remove(agentID);
791 }
792 }
793
794 public bool hasAgentBeenInvitedToGroupChatSession(UUID agentID, UUID groupID)
795 {
796 // If we're tracking this group, and we can find them in the tracking, then they've been invited
797 return m_groupsAgentsInvitedToChatSession.ContainsKey(groupID)
798 && m_groupsAgentsInvitedToChatSession[groupID].Contains(agentID);
799 }
800
801 public bool hasAgentDroppedGroupChatSession(UUID agentID, UUID groupID)
802 {
803 // If we're tracking drops for this group,
804 // and we find them, well... then they've dropped
805 return m_groupsAgentsDroppedFromChatSession.ContainsKey(groupID)
806 && m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID);
807 }
808
809 public void AgentDroppedFromGroupChatSession(UUID agentID, UUID groupID)
810 {
811 if (m_groupsAgentsDroppedFromChatSession.ContainsKey(groupID))
812 {
813 // If not in dropped list, add
814 if (!m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID))
815 {
816 m_groupsAgentsDroppedFromChatSession[groupID].Add(agentID);
817 }
818 }
819 }
820
821 public void AgentInvitedToGroupChatSession(UUID agentID, UUID groupID)
822 {
823 // Add Session Status if it doesn't exist for this session
824 CreateGroupChatSessionTracking(groupID);
825
826 // If nessesary, remove from dropped list
827 if (m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID))
828 {
829 m_groupsAgentsDroppedFromChatSession[groupID].Remove(agentID);
830 }
831 }
832
833 private void CreateGroupChatSessionTracking(UUID groupID)
834 {
835 if (!m_groupsAgentsDroppedFromChatSession.ContainsKey(groupID))
836 {
837 m_groupsAgentsDroppedFromChatSession.Add(groupID, new List<UUID>());
838 m_groupsAgentsInvitedToChatSession.Add(groupID, new List<UUID>());
839 }
840
841 }
842 #endregion 759 #endregion
843 760
844 #region XmlRpcHashtableMarshalling 761 #region XmlRpcHashtableMarshalling
@@ -932,84 +849,50 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
932 /// </summary> 849 /// </summary>
933 private Hashtable XmlRpcCall(UUID requestingAgentID, string function, Hashtable param) 850 private Hashtable XmlRpcCall(UUID requestingAgentID, string function, Hashtable param)
934 { 851 {
935 XmlRpcResponse resp = null; 852 string UserService;
936 string CacheKey = null; 853 UUID SessionID;
937 854 GetClientGroupRequestID(requestingAgentID, out UserService, out SessionID);
938 // Only bother with the cache if it isn't disabled. 855 param.Add("requestingAgentID", requestingAgentID.ToString());
939 if (m_cacheTimeout > 0) 856 param.Add("RequestingAgentUserService", UserService);
940 { 857 param.Add("RequestingSessionID", SessionID.ToString());
941 if (!function.StartsWith("groups.get"))
942 {
943 // Any and all updates cause the cache to clear
944 m_memoryCache.Clear();
945 }
946 else
947 {
948 StringBuilder sb = new StringBuilder(requestingAgentID + function);
949 foreach (object key in param.Keys)
950 {
951 if (param[key] != null)
952 {
953 sb.AppendFormat(",{0}:{1}", key.ToString(), param[key].ToString());
954 }
955 }
956
957 CacheKey = sb.ToString();
958 m_memoryCache.TryGetValue(CacheKey, out resp);
959 }
960
961 }
962 858
963 if( resp == null )
964 {
965 string UserService;
966 UUID SessionID;
967 GetClientGroupRequestID(requestingAgentID, out UserService, out SessionID);
968 param.Add("requestingAgentID", requestingAgentID.ToString());
969 param.Add("RequestingAgentUserService", UserService);
970 param.Add("RequestingSessionID", SessionID.ToString());
971 859
860 param.Add("ReadKey", m_groupReadKey);
861 param.Add("WriteKey", m_groupWriteKey);
972 862
973 param.Add("ReadKey", m_groupReadKey);
974 param.Add("WriteKey", m_groupWriteKey);
975 863
864 IList parameters = new ArrayList();
865 parameters.Add(param);
976 866
977 IList parameters = new ArrayList(); 867 ConfigurableKeepAliveXmlRpcRequest req;
978 parameters.Add(param); 868 req = new ConfigurableKeepAliveXmlRpcRequest(function, parameters, m_disableKeepAlive);
979
980 ConfigurableKeepAliveXmlRpcRequest req;
981 req = new ConfigurableKeepAliveXmlRpcRequest(function, parameters, m_disableKeepAlive);
982 869
870 XmlRpcResponse resp = null;
983 871
984 try 872 try
985 { 873 {
986 resp = req.Send(m_groupsServerURI, 10000); 874 resp = req.Send(m_serviceURL, 10000);
875 }
876 catch (Exception e)
877 {
878
987 879
988 if ((m_cacheTimeout > 0) && (CacheKey != null)) 880 m_log.ErrorFormat("[XMLRPCGROUPDATA]: An error has occured while attempting to access the XmlRpcGroups server method: {0}", function);
989 { 881 m_log.ErrorFormat("[XMLRPCGROUPDATA]: {0} ", e.ToString());
990 m_memoryCache.AddOrUpdate(CacheKey, resp, TimeSpan.FromSeconds(m_cacheTimeout));
991 }
992 882
883 foreach (string ResponseLine in req.RequestResponse.Split(new string[] { Environment.NewLine },StringSplitOptions.None))
884 {
885 m_log.ErrorFormat("[XMLRPCGROUPDATA]: {0} ", ResponseLine);
993 } 886 }
994 catch (Exception e) 887
888 foreach (string key in param.Keys)
995 { 889 {
996 m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: An error has occured while attempting to access the XmlRpcGroups server method: {0}", function); 890 m_log.WarnFormat("[XMLRPCGROUPDATA]: {0} :: {1}", key, param[key].ToString());
997 m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: {0} ", e.ToString());
998
999 foreach (string ResponseLine in req.RequestResponse.Split(new string[] { Environment.NewLine }, StringSplitOptions.None))
1000 {
1001 m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: {0} ", ResponseLine);
1002 }
1003
1004 foreach (string key in param.Keys)
1005 {
1006 m_log.WarnFormat("[XMLRPC-GROUPS-CONNECTOR]: {0} :: {1}", key, param[key].ToString());
1007 }
1008
1009 Hashtable respData = new Hashtable();
1010 respData.Add("error", e.ToString());
1011 return respData;
1012 } 891 }
892
893 Hashtable respData = new Hashtable();
894 respData.Add("error", e.ToString());
895 return respData;
1013 } 896 }
1014 897
1015 if (resp.Value is Hashtable) 898 if (resp.Value is Hashtable)
@@ -1023,21 +906,21 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1023 return respData; 906 return respData;
1024 } 907 }
1025 908
1026 m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: The XmlRpc server returned a {1} instead of a hashtable for {0}", function, resp.Value.GetType().ToString()); 909 m_log.ErrorFormat("[XMLRPCGROUPDATA]: The XmlRpc server returned a {1} instead of a hashtable for {0}", function, resp.Value.GetType().ToString());
1027 910
1028 if (resp.Value is ArrayList) 911 if (resp.Value is ArrayList)
1029 { 912 {
1030 ArrayList al = (ArrayList)resp.Value; 913 ArrayList al = (ArrayList)resp.Value;
1031 m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: Contains {0} elements", al.Count); 914 m_log.ErrorFormat("[XMLRPCGROUPDATA]: Contains {0} elements", al.Count);
1032 915
1033 foreach (object o in al) 916 foreach (object o in al)
1034 { 917 {
1035 m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: {0} :: {1}", o.GetType().ToString(), o.ToString()); 918 m_log.ErrorFormat("[XMLRPCGROUPDATA]: {0} :: {1}", o.GetType().ToString(), o.ToString());
1036 } 919 }
1037 } 920 }
1038 else 921 else
1039 { 922 {
1040 m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: Function returned: {0}", resp.Value.ToString()); 923 m_log.ErrorFormat("[XMLRPCGROUPDATA]: Function returned: {0}", resp.Value.ToString());
1041 } 924 }
1042 925
1043 Hashtable error = new Hashtable(); 926 Hashtable error = new Hashtable();
@@ -1047,16 +930,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1047 930
1048 private void LogRespDataToConsoleError(Hashtable respData) 931 private void LogRespDataToConsoleError(Hashtable respData)
1049 { 932 {
1050 m_log.Error("[XMLRPC-GROUPS-CONNECTOR]: Error:"); 933 m_log.Error("[XMLRPCGROUPDATA]: Error:");
1051 934
1052 foreach (string key in respData.Keys) 935 foreach (string key in respData.Keys)
1053 { 936 {
1054 m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: Key: {0}", key); 937 m_log.ErrorFormat("[XMLRPCGROUPDATA]: Key: {0}", key);
1055 938
1056 string[] lines = respData[key].ToString().Split(new char[] { '\n' }); 939 string[] lines = respData[key].ToString().Split(new char[] { '\n' });
1057 foreach (string line in lines) 940 foreach (string line in lines)
1058 { 941 {
1059 m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: {0}", line); 942 m_log.ErrorFormat("[XMLRPCGROUPDATA]: {0}", line);
1060 } 943 }
1061 944
1062 } 945 }
@@ -1065,8 +948,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1065 948
1066 /// <summary> 949 /// <summary>
1067 /// Group Request Tokens are an attempt to allow the groups service to authenticate 950 /// Group Request Tokens are an attempt to allow the groups service to authenticate
1068 /// requests. 951 /// requests. Currently uses UserService, AgentID, and SessionID
1069 /// TODO: This broke after the big grid refactor, either find a better way, or discard this 952 /// TODO: Find a better way to do this.
1070 /// </summary> 953 /// </summary>
1071 /// <param name="client"></param> 954 /// <param name="client"></param>
1072 /// <returns></returns> 955 /// <returns></returns>