diff options
Diffstat (limited to '')
-rw-r--r-- | Common/OpenGrid.Framework.Communications/SandBoxManager.cs | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/Common/OpenGrid.Framework.Communications/SandBoxManager.cs b/Common/OpenGrid.Framework.Communications/SandBoxManager.cs new file mode 100644 index 0000000..4094658 --- /dev/null +++ b/Common/OpenGrid.Framework.Communications/SandBoxManager.cs | |||
@@ -0,0 +1,125 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using OpenSim.Framework; | ||
5 | using OpenSim.Framework.Types; | ||
6 | |||
7 | using libsecondlife; | ||
8 | |||
9 | namespace OpenGrid.Framework.Communications | ||
10 | { | ||
11 | public class SandBoxManager | ||
12 | { | ||
13 | protected Dictionary<ulong, RegionInfo> regions = new Dictionary<ulong, RegionInfo>(); | ||
14 | protected Dictionary<ulong, RegionCommsHostBase> regionHosts = new Dictionary<ulong, RegionCommsHostBase>(); | ||
15 | |||
16 | public SandBoxManager() | ||
17 | { | ||
18 | |||
19 | } | ||
20 | |||
21 | /// <summary> | ||
22 | /// Main Register a region method with the CommsManager. | ||
23 | /// Should do anything that is needed and also call the RegisterRegion method in the gridserver class | ||
24 | /// to inform the grid server (in grid mode). | ||
25 | /// </summary> | ||
26 | /// <param name="regionInfo"></param> | ||
27 | /// <returns></returns> | ||
28 | public RegionCommsHostBase RegisterRegion(RegionInfo regionInfo) | ||
29 | { | ||
30 | //Console.WriteLine("CommsManager - Region " + regionInfo.RegionHandle + " , " + regionInfo.RegionLocX + " , "+ regionInfo.RegionLocY +" is registering"); | ||
31 | if (!this.regions.ContainsKey((uint)regionInfo.RegionHandle)) | ||
32 | { | ||
33 | //Console.WriteLine("CommsManager - Adding Region " + regionInfo.RegionHandle ); | ||
34 | this.regions.Add(regionInfo.RegionHandle, regionInfo); | ||
35 | RegionCommsHostBase regionHost = new RegionCommsHostBase(); | ||
36 | this.regionHosts.Add(regionInfo.RegionHandle, regionHost); | ||
37 | |||
38 | return regionHost; | ||
39 | } | ||
40 | |||
41 | //already in our list of regions so for now lets return null | ||
42 | return null; | ||
43 | } | ||
44 | |||
45 | /// <summary> | ||
46 | /// In the current class structure this shouldn't be here as it should only be in the gridserver class | ||
47 | /// but having it there in sandbox mode makes things very difficult, so for now until something is sorted out | ||
48 | /// it will have to be here as well | ||
49 | /// </summary> | ||
50 | /// <param name="regionInfo"></param> | ||
51 | /// <returns></returns> | ||
52 | public List<RegionInfo> RequestNeighbours(RegionInfo regionInfo) | ||
53 | { | ||
54 | // Console.WriteLine("Finding Neighbours to " + regionInfo.RegionHandle); | ||
55 | List<RegionInfo> neighbours = new List<RegionInfo>(); | ||
56 | |||
57 | foreach (RegionInfo reg in this.regions.Values) | ||
58 | { | ||
59 | // Console.WriteLine("CommsManager- RequestNeighbours() checking region " + reg.RegionLocX + " , "+ reg.RegionLocY); | ||
60 | if (reg.RegionHandle != regionInfo.RegionHandle) | ||
61 | { | ||
62 | //Console.WriteLine("CommsManager- RequestNeighbours() - found a different region in list, checking location"); | ||
63 | if ((reg.RegionLocX > (regionInfo.RegionLocX - 2)) && (reg.RegionLocX < (regionInfo.RegionLocX + 2))) | ||
64 | { | ||
65 | if ((reg.RegionLocY > (regionInfo.RegionLocY - 2)) && (reg.RegionLocY < (regionInfo.RegionLocY + 2))) | ||
66 | { | ||
67 | neighbours.Add(reg); | ||
68 | } | ||
69 | } | ||
70 | } | ||
71 | } | ||
72 | return neighbours; | ||
73 | } | ||
74 | |||
75 | /// <summary> | ||
76 | /// informs a neighbouring sim to expect a child agent | ||
77 | /// I guess if we are going to stick with the current class structure then we need a intersim class | ||
78 | /// but think we need to really rethink the class structure as currently it makes things very messy for sandbox mode | ||
79 | /// </summary> | ||
80 | /// <param name="regionHandle"></param> | ||
81 | /// <param name="agentData"></param> | ||
82 | /// <returns></returns> | ||
83 | public bool InformNeighbourOfChildAgent(ulong regionHandle, AgentCircuitData agentData) //should change from agentCircuitData | ||
84 | { | ||
85 | //Console.WriteLine("CommsManager- Trying to Inform a region to expect child agent"); | ||
86 | if (this.regionHosts.ContainsKey(regionHandle)) | ||
87 | { | ||
88 | // Console.WriteLine("CommsManager- Informing a region to expect child agent"); | ||
89 | this.regionHosts[regionHandle].TriggerExpectUser(regionHandle, agentData); | ||
90 | return true; | ||
91 | } | ||
92 | return false; | ||
93 | } | ||
94 | |||
95 | /// <summary> | ||
96 | /// Is a Sandbox mode method, used by the local Login server to inform a region of a connection user/session | ||
97 | /// </summary> | ||
98 | /// <param name="regionHandle"></param> | ||
99 | /// <param name="loginData"></param> | ||
100 | /// <returns></returns> | ||
101 | public bool AddNewSession(ulong regionHandle, Login loginData) | ||
102 | { | ||
103 | //Console.WriteLine(" comms manager been told to expect new user"); | ||
104 | AgentCircuitData agent = new AgentCircuitData(); | ||
105 | agent.AgentID = loginData.Agent; | ||
106 | agent.firstname = loginData.First; | ||
107 | agent.lastname = loginData.Last; | ||
108 | agent.SessionID = loginData.Session; | ||
109 | agent.SecureSessionID = loginData.SecureSession; | ||
110 | agent.circuitcode = loginData.CircuitCode; | ||
111 | agent.BaseFolder = loginData.BaseFolder; | ||
112 | agent.InventoryFolder = loginData.InventoryFolder; | ||
113 | agent.startpos = new LLVector3(128, 128, 70); | ||
114 | |||
115 | if (this.regionHosts.ContainsKey(regionHandle)) | ||
116 | { | ||
117 | this.regionHosts[regionHandle].TriggerExpectUser(regionHandle, agent); | ||
118 | return true; | ||
119 | } | ||
120 | |||
121 | // region not found | ||
122 | return false; | ||
123 | } | ||
124 | } | ||
125 | } | ||