aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ogs/gridserver/src/SimProfiles.cs
diff options
context:
space:
mode:
Diffstat (limited to 'ogs/gridserver/src/SimProfiles.cs')
-rw-r--r--ogs/gridserver/src/SimProfiles.cs111
1 files changed, 111 insertions, 0 deletions
diff --git a/ogs/gridserver/src/SimProfiles.cs b/ogs/gridserver/src/SimProfiles.cs
new file mode 100644
index 0000000..91a92ea
--- /dev/null
+++ b/ogs/gridserver/src/SimProfiles.cs
@@ -0,0 +1,111 @@
1/*
2Copyright (c) OpenGrid project, http://osgrid.org/
3
4
5* All rights reserved.
6*
7* Redistribution and use in source and binary forms, with or without
8* modification, are permitted provided that the following conditions are met:
9* * Redistributions of source code must retain the above copyright
10* notice, this list of conditions and the following disclaimer.
11* * Redistributions in binary form must reproduce the above copyright
12* notice, this list of conditions and the following disclaimer in the
13* documentation and/or other materials provided with the distribution.
14* * Neither the name of the <organization> nor the
15* names of its contributors may be used to endorse or promote products
16* derived from this software without specific prior written permission.
17*
18* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
19* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
22* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28*/
29
30using System;
31using System.Text;
32using System.Collections;
33using System.Collections.Generic;
34using libsecondlife;
35using ServerConsole;
36
37namespace OpenGridServices
38{
39 /// <summary>
40 /// </summary>
41 public class SimProfileManager {
42
43 public Dictionary<LLUUID, SimProfile> SimProfiles = new Dictionary<LLUUID, SimProfile>();
44
45 public SimProfileManager() {
46 }
47
48 public void InitSimProfiles() {
49 // TODO: need to load from database
50 }
51
52 public SimProfile GetProfileByHandle(ulong reqhandle) {
53 foreach (libsecondlife.LLUUID UUID in SimProfiles.Keys) {
54 if(SimProfiles[UUID].regionhandle==reqhandle) return SimProfiles[UUID];
55 }
56 return null;
57 }
58
59 public SimProfile GetProfileByLLUUID(LLUUID ProfileLLUUID) {
60 return SimProfiles[ProfileLLUUID];
61 }
62
63 public bool AuthenticateSim(LLUUID RegionUUID, uint regionhandle, string simrecvkey) {
64 SimProfile TheSim=GetProfileByHandle(regionhandle);
65 if(TheSim != null)
66 if(TheSim.recvkey==simrecvkey) {
67 return true;
68 } else {
69 return false;
70 } else return false;
71
72 }
73
74 public SimProfile CreateNewProfile(string regionname, string caps_url, string sim_ip, uint sim_port, uint RegionLocX, uint RegionLocY, string sendkey, string recvkey) {
75 SimProfile newprofile = new SimProfile();
76 newprofile.regionname=regionname;
77 newprofile.sim_ip=sim_ip;
78 newprofile.sim_port=sim_port;
79 newprofile.RegionLocX=RegionLocX;
80 newprofile.RegionLocY=RegionLocY;
81 newprofile.caps_url="http://" + sim_ip + ":9000/";
82 newprofile.sendkey=sendkey;
83 newprofile.recvkey=recvkey;
84 newprofile.regionhandle=Util.UIntsToLong((RegionLocX*256), (RegionLocY*256));
85 newprofile.UUID=LLUUID.Random();
86 this.SimProfiles.Add(newprofile.UUID,newprofile);
87 return newprofile;
88 }
89
90 }
91
92 public class SimProfile {
93 public LLUUID UUID;
94 public ulong regionhandle;
95 public string regionname;
96 public string sim_ip;
97 public uint sim_port;
98 public string caps_url;
99 public uint RegionLocX;
100 public uint RegionLocY;
101 public string sendkey;
102 public string recvkey;
103
104
105 public SimProfile() {
106 }
107
108
109 }
110
111}