aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/UserServer/UserLoginService.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Grid/UserServer/UserLoginService.cs')
-rw-r--r--OpenSim/Grid/UserServer/UserLoginService.cs185
1 files changed, 124 insertions, 61 deletions
diff --git a/OpenSim/Grid/UserServer/UserLoginService.cs b/OpenSim/Grid/UserServer/UserLoginService.cs
index bbef4b2..0af5790 100644
--- a/OpenSim/Grid/UserServer/UserLoginService.cs
+++ b/OpenSim/Grid/UserServer/UserLoginService.cs
@@ -54,76 +54,139 @@ namespace OpenSim.Grid.UserServer
54 /// <param name="theUser">The user profile</param> 54 /// <param name="theUser">The user profile</param>
55 public override void CustomiseResponse(LoginResponse response, UserProfileData theUser) 55 public override void CustomiseResponse(LoginResponse response, UserProfileData theUser)
56 { 56 {
57 // Load information from the gridserver 57 bool tryDefault = false;
58 System.Console.WriteLine("Load information from the gridserver");
58 RegionProfileData SimInfo = new RegionProfileData(); 59 RegionProfileData SimInfo = new RegionProfileData();
59 SimInfo =
60 SimInfo.RequestSimProfileData(theUser.currentAgent.currentHandle, m_config.GridServerURL,
61 m_config.GridSendKey, m_config.GridRecvKey);
62
63 // Customise the response
64 // Home Location
65 response.Home = "{'region_handle':[r" + (SimInfo.regionLocX*256).ToString() + ",r" +
66 (SimInfo.regionLocY*256).ToString() + "], " +
67 "'position':[r" + theUser.homeLocation.X.ToString() + ",r" +
68 theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "], " +
69 "'look_at':[r" + theUser.homeLocation.X.ToString() + ",r" +
70 theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "]}";
71
72 // Destination
73 MainLog.Instance.Verbose("CUSTOMISERESPONSE: Region X: " + SimInfo.regionLocX + "; Region Y: " +
74 SimInfo.regionLocY);
75 response.SimAddress = Util.GetHostFromDNS(SimInfo.serverIP).ToString();
76 response.SimPort = (Int32) SimInfo.serverPort;
77 response.RegionX = SimInfo.regionLocX;
78 response.RegionY = SimInfo.regionLocY;
79
80 //Not sure if the + "/CAPS/" should in fact be +"CAPS/" depending if there is already a / as part of httpServerURI
81 string capsPath = Util.GetRandomCapsPath();
82 response.SeedCapability = SimInfo.httpServerURI + "CAPS/" + capsPath + "0000/";
83
84 // Notify the target of an incoming user
85 MainLog.Instance.Verbose("Notifying " + SimInfo.regionName + " (" + SimInfo.serverURI + ")");
86
87 // Prepare notification
88 Hashtable SimParams = new Hashtable();
89 SimParams["session_id"] = theUser.currentAgent.sessionID.ToString();
90 SimParams["secure_session_id"] = theUser.currentAgent.secureSessionID.ToString();
91 SimParams["firstname"] = theUser.username;
92 SimParams["lastname"] = theUser.surname;
93 SimParams["agent_id"] = theUser.UUID.ToString();
94 SimParams["circuit_code"] = (Int32) Convert.ToUInt32(response.CircuitCode);
95 SimParams["startpos_x"] = theUser.currentAgent.currentPos.X.ToString();
96 SimParams["startpos_y"] = theUser.currentAgent.currentPos.Y.ToString();
97 SimParams["startpos_z"] = theUser.currentAgent.currentPos.Z.ToString();
98 SimParams["regionhandle"] = theUser.currentAgent.currentHandle.ToString();
99 SimParams["caps_path"] = capsPath;
100 ArrayList SendParams = new ArrayList();
101 SendParams.Add(SimParams);
102
103 // Update agent with target sim
104 theUser.currentAgent.currentRegion = SimInfo.UUID;
105 theUser.currentAgent.currentHandle = SimInfo.regionHandle;
106
107 MainLog.Instance.Verbose("Informing region --> " + SimInfo.httpServerURI);
108 // Send
109 try 60 try
110 { 61 {
62 SimInfo =
63 SimInfo.RequestSimProfileData(theUser.currentAgent.currentHandle, m_config.GridServerURL,
64 m_config.GridSendKey, m_config.GridRecvKey);
65
66 // Customise the response
67 System.Console.WriteLine("Home Location");
68 response.Home = "{'region_handle':[r" + (SimInfo.regionLocX * 256).ToString() + ",r" +
69 (SimInfo.regionLocY * 256).ToString() + "], " +
70 "'position':[r" + theUser.homeLocation.X.ToString() + ",r" +
71 theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "], " +
72 "'look_at':[r" + theUser.homeLocation.X.ToString() + ",r" +
73 theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "]}";
74
75 // Destination
76 MainLog.Instance.Verbose("CUSTOMISERESPONSE: Region X: " + SimInfo.regionLocX + "; Region Y: " +
77 SimInfo.regionLocY);
78 response.SimAddress = Util.GetHostFromDNS(SimInfo.serverIP).ToString();
79 response.SimPort = (Int32)SimInfo.serverPort;
80 response.RegionX = SimInfo.regionLocX;
81 response.RegionY = SimInfo.regionLocY;
82
83 //Not sure if the + "/CAPS/" should in fact be +"CAPS/" depending if there is already a / as part of httpServerURI
84 string capsPath = Util.GetRandomCapsPath();
85 response.SeedCapability = SimInfo.httpServerURI + "CAPS/" + capsPath + "0000/";
86
87 // Notify the target of an incoming user
88 MainLog.Instance.Verbose("Notifying " + SimInfo.regionName + " (" + SimInfo.serverURI + ")");
89
90 // Prepare notification
91 Hashtable SimParams = new Hashtable();
92 SimParams["session_id"] = theUser.currentAgent.sessionID.ToString();
93 SimParams["secure_session_id"] = theUser.currentAgent.secureSessionID.ToString();
94 SimParams["firstname"] = theUser.username;
95 SimParams["lastname"] = theUser.surname;
96 SimParams["agent_id"] = theUser.UUID.ToString();
97 SimParams["circuit_code"] = (Int32)Convert.ToUInt32(response.CircuitCode);
98 SimParams["startpos_x"] = theUser.currentAgent.currentPos.X.ToString();
99 SimParams["startpos_y"] = theUser.currentAgent.currentPos.Y.ToString();
100 SimParams["startpos_z"] = theUser.currentAgent.currentPos.Z.ToString();
101 SimParams["regionhandle"] = theUser.currentAgent.currentHandle.ToString();
102 SimParams["caps_path"] = capsPath;
103 ArrayList SendParams = new ArrayList();
104 SendParams.Add(SimParams);
105
106 // Update agent with target sim
107 theUser.currentAgent.currentRegion = SimInfo.UUID;
108 theUser.currentAgent.currentHandle = SimInfo.regionHandle;
109
110 MainLog.Instance.Verbose("Informing region --> " + SimInfo.httpServerURI);
111 // Send
112
111 XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams); 113 XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams);
112 XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 6000); 114 XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 6000);
113 } 115 }
114 catch (WebException e) 116 catch (Exception e)
115 { 117 {
116 switch (e.Status) 118 tryDefault = true;
119 }
120 if(tryDefault)
121 {
122 // Send him to default region instead
123 // Load information from the gridserver
124
125 ulong defaultHandle = (((ulong)m_config.DefaultX * 256) << 32) | ((ulong) m_config.DefaultY * 256);
126 MainLog.Instance.Warn("Home region not available: sending to default region " + defaultHandle.ToString());
127 SimInfo = new RegionProfileData();
128 try
117 { 129 {
118 case WebExceptionStatus.Timeout: 130 SimInfo =
119 //TODO: Send him to nearby or default region instead 131 SimInfo.RequestSimProfileData(defaultHandle, m_config.GridServerURL,
120 MainLog.Instance.Verbose("Unable to connect to " + SimInfo.regionName + " (" + SimInfo.serverURI + 132 m_config.GridSendKey, m_config.GridRecvKey);
121 ")"); 133
122 break; 134 // Customise the response
123 135 System.Console.WriteLine("Home Location");
124 default: 136 response.Home = "{'region_handle':[r" + (SimInfo.regionLocX * 256).ToString() + ",r" +
125 throw; 137 (SimInfo.regionLocY * 256).ToString() + "], " +
138 "'position':[r" + theUser.homeLocation.X.ToString() + ",r" +
139 theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "], " +
140 "'look_at':[r" + theUser.homeLocation.X.ToString() + ",r" +
141 theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "]}";
142
143 // Destination
144 MainLog.Instance.Verbose("CUSTOMISERESPONSE: Region X: " + SimInfo.regionLocX + "; Region Y: " +
145 SimInfo.regionLocY);
146 response.SimAddress = Util.GetHostFromDNS(SimInfo.serverIP).ToString();
147 response.SimPort = (Int32)SimInfo.serverPort;
148 response.RegionX = SimInfo.regionLocX;
149 response.RegionY = SimInfo.regionLocY;
150
151 //Not sure if the + "/CAPS/" should in fact be +"CAPS/" depending if there is already a / as part of httpServerURI
152 string capsPath = Util.GetRandomCapsPath();
153 response.SeedCapability = SimInfo.httpServerURI + "CAPS/" + capsPath + "0000/";
154
155 // Notify the target of an incoming user
156 MainLog.Instance.Verbose("Notifying " + SimInfo.regionName + " (" + SimInfo.serverURI + ")");
157
158 // Update agent with target sim
159 theUser.currentAgent.currentRegion = SimInfo.UUID;
160 theUser.currentAgent.currentHandle = SimInfo.regionHandle;
161
162 // Prepare notification
163 Hashtable SimParams = new Hashtable();
164 SimParams["session_id"] = theUser.currentAgent.sessionID.ToString();
165 SimParams["secure_session_id"] = theUser.currentAgent.secureSessionID.ToString();
166 SimParams["firstname"] = theUser.username;
167 SimParams["lastname"] = theUser.surname;
168 SimParams["agent_id"] = theUser.UUID.ToString();
169 SimParams["circuit_code"] = (Int32)Convert.ToUInt32(response.CircuitCode);
170 SimParams["startpos_x"] = theUser.currentAgent.currentPos.X.ToString();
171 SimParams["startpos_y"] = theUser.currentAgent.currentPos.Y.ToString();
172 SimParams["startpos_z"] = theUser.currentAgent.currentPos.Z.ToString();
173 SimParams["regionhandle"] = theUser.currentAgent.currentHandle.ToString();
174 SimParams["caps_path"] = capsPath;
175 ArrayList SendParams = new ArrayList();
176 SendParams.Add(SimParams);
177
178 MainLog.Instance.Verbose("Informing region --> " + SimInfo.httpServerURI);
179 // Send
180 XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams);
181 XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 6000);
126 } 182 }
183
184 catch (Exception e)
185 {
186 MainLog.Instance.Warn("Default region also not available");
187 MainLog.Instance.Verbose(e.ToString());
188 }
189
127 } 190 }
128 } 191 }
129 } 192 }