diff --git a/gridserver/src/GridHttp.cs b/gridserver/src/GridHttp.cs index 41cbdb98e7..510f490fec 100644 --- a/gridserver/src/GridHttp.cs +++ b/gridserver/src/GridHttp.cs @@ -66,13 +66,13 @@ namespace OpenGridServices } static string ParseXMLRPC(string requestBody) { + try{ XmlRpcRequest request = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(requestBody); Hashtable requestData = (Hashtable)request.Params[0]; switch(request.MethodName) { case "get_sim_info": - Console.WriteLine("get_sim_info"); - uint req_handle=(uint)requestData["region_handle"]; + ulong req_handle=(ulong)Convert.ToInt64(requestData["region_handle"]); SimProfile TheSim = OpenGrid_Main.thegrid._regionmanager.GetProfileByHandle(req_handle); string RecvKey=""; string caller=(string)requestData["caller"]; @@ -86,7 +86,18 @@ namespace OpenGridServices } if((TheSim!=null) && (string)requestData["authkey"]==RecvKey) { XmlRpcResponse SimInfoResp = new XmlRpcResponse(); - SimInfoResp.Value=TheSim; + Hashtable SimInfoData = new Hashtable(); + SimInfoData["UUID"]=TheSim.UUID.ToString(); + SimInfoData["regionhandle"]=TheSim.regionhandle.ToString(); + SimInfoData["regionname"]=TheSim.regionname; + SimInfoData["sim_ip"]=TheSim.sim_ip; + SimInfoData["sim_port"]=TheSim.sim_port.ToString(); + SimInfoData["caps_url"]=TheSim.caps_url; + SimInfoData["RegionLocX"]=TheSim.RegionLocX.ToString(); + SimInfoData["RegionLocY"]=TheSim.RegionLocY.ToString(); + SimInfoData["sendkey"]=TheSim.sendkey; + SimInfoData["recvkey"]=TheSim.recvkey; + SimInfoResp.Value=SimInfoData; return(XmlRpcResponseSerializer.Singleton.Serialize(SimInfoResp)); } else { XmlRpcResponse SimErrorResp = new XmlRpcResponse(); @@ -97,7 +108,9 @@ namespace OpenGridServices } break; } - + } catch(Exception e) { + Console.WriteLine(e.ToString()); + } return ""; } @@ -142,7 +155,7 @@ namespace OpenGridServices byte[] buffer = System.Text.Encoding.Unicode.GetBytes(responseString); System.IO.Stream output = response.OutputStream; response.SendChunked=false; - encoding = System.Text.Encoding.UTF8; + encoding = System.Text.Encoding.Unicode; response.ContentEncoding = encoding; response.ContentLength64=buffer.Length; output.Write(buffer,0,buffer.Length); diff --git a/gridserver/src/Main.cs b/gridserver/src/Main.cs index eb7c1fd937..d29a1ae50e 100644 --- a/gridserver/src/Main.cs +++ b/gridserver/src/Main.cs @@ -85,6 +85,10 @@ namespace OpenGridServices ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Startup() - Starting HTTP process"); _httpd = new GridHTTPServer(); + + this._regionmanager=new SimProfileManager(); + _regionmanager.CreateNewProfile("OpenSim Test", "http://there-is-no-caps.com", "4.78.190.75", 9000, 997, 996, this.UserSendKey, this.UserRecvKey); + } } } diff --git a/gridserver/src/SimProfiles.cs b/gridserver/src/SimProfiles.cs index 7efb78586e..d5aaab755e 100644 --- a/gridserver/src/SimProfiles.cs +++ b/gridserver/src/SimProfiles.cs @@ -78,9 +78,11 @@ namespace OpenGridServices newprofile.sim_port=sim_port; newprofile.RegionLocX=RegionLocX; newprofile.RegionLocY=RegionLocY; + newprofile.caps_url="http://" + sim_ip + ":12036"; newprofile.sendkey=sendkey; newprofile.recvkey=recvkey; newprofile.regionhandle=Util.UIntsToLong((RegionLocX*256), (RegionLocY*256)); + newprofile.UUID=LLUUID.Random(); this.SimProfiles.Add(newprofile.UUID,newprofile); return newprofile; } diff --git a/userserver/src/UserHttp.cs b/userserver/src/UserHttp.cs index e520a41e49..eff63c9989 100644 --- a/userserver/src/UserHttp.cs +++ b/userserver/src/UserHttp.cs @@ -139,10 +139,13 @@ namespace OpenGridServices LoginGoodData["login_flags"]=LoginFlags; LoginGoodData["seed_capability"]="http://" + SimInfo.sim_ip + ":12043" + "/cap/" + TheUser.CurrentSecureSessionID.Combine(TheUser.CurrentSessionID).Combine(AgentID); - + + try { LoginGoodResp.Value=LoginGoodData; return(XmlRpcResponseSerializer.Singleton.Serialize(LoginGoodResp)); - + } catch (Exception E) { + Console.WriteLine(E.ToString()); + } break; } diff --git a/userserver/src/UserProfiles.cs b/userserver/src/UserProfiles.cs index 78d106452b..46d4add581 100644 --- a/userserver/src/UserProfiles.cs +++ b/userserver/src/UserProfiles.cs @@ -78,6 +78,7 @@ namespace OpenGridServices public UserProfile CreateNewProfile(string firstname, string lastname, string MD5passwd) { UserProfile newprofile = new UserProfile(); + newprofile.homeregionhandle=Util.UIntsToLong((997*256), (996*256)); newprofile.firstname=firstname; newprofile.lastname=lastname; newprofile.MD5passwd=MD5passwd; @@ -92,7 +93,7 @@ namespace OpenGridServices public string firstname; public string lastname; - public uint homeregionhandle; + public ulong homeregionhandle; public LLVector3 homepos; public LLVector3 homelookat; @@ -112,7 +113,7 @@ namespace OpenGridServices Circuits = new Dictionary(); InventoryFolders = new Dictionary(); InventoryItems = new Dictionary(); - homeregionhandle=0; + homeregionhandle=Util.UIntsToLong((997*256), (996*256));; } public void InitSessionData() { @@ -158,20 +159,28 @@ namespace OpenGridServices public string recvkey; - public SimProfile LoadFromGrid(uint region_handle, string GridURL, string SendKey, string RecvKey) { + public SimProfile LoadFromGrid(ulong region_handle, string GridURL, string SendKey, string RecvKey) { + try { Hashtable GridReqParams = new Hashtable(); - GridReqParams["region_handle"]=region_handle; + GridReqParams["region_handle"]=region_handle.ToString(); GridReqParams["caller"]="userserver"; GridReqParams["authkey"]=SendKey; ArrayList SendParams = new ArrayList(); SendParams.Add(GridReqParams); - XmlRpcResponse GridResp = new XmlRpcRequest("get_sim_info",SendParams).Send(GridURL,3000); - - return (SimProfile)GridResp.Value; + XmlRpcRequest GridReq = new XmlRpcRequest("get_sim_info",GridReqParams); + + XmlRpcResponse GridResp = GridReq.Send(GridURL,3000); + + Hashtable RespData=(Hashtable)GridResp.Value; + Console.WriteLine(RespData.ToString()); + } catch(Exception e) { + Console.WriteLine(e.ToString()); + } + return this; } public SimProfile() { - } + } } diff --git a/userserver/src/Util.cs b/userserver/src/Util.cs new file mode 100644 index 0000000000..1efa4715aa --- /dev/null +++ b/userserver/src/Util.cs @@ -0,0 +1,87 @@ +/* +Copyright (c) OpenSim project, http://osgrid.org/ + +* Copyright (c) , +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +using System; +using System.Collections.Generic; +using System.Threading; +using libsecondlife; +using libsecondlife.Packets; + +namespace OpenGridServices +{ + /// + /// + /// + public class Util + { + public static ulong UIntsToLong(uint X, uint Y) + { + return Helpers.UIntsToLong(X,Y); + } + public Util() + { + + } + } + + public class QueItem { + public QueItem() + { + } + + public Packet Packet; + public bool Incoming; + } + + + public class BlockingQueue< T > { + private Queue< T > _queue = new Queue< T >(); + private object _queueSync = new object(); + + public void Enqueue(T value) + { + lock(_queueSync) + { + _queue.Enqueue(value); + Monitor.Pulse(_queueSync); + } + } + + public T Dequeue() + { + lock(_queueSync) + { + if( _queue.Count < 1) + Monitor.Wait(_queueSync); + + return _queue.Dequeue(); + } + } + } +}