aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/LocalServers/LocalGridServers/LocalGrid.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/LocalServers/LocalGridServers/LocalGrid.cs')
-rw-r--r--src/LocalServers/LocalGridServers/LocalGrid.cs205
1 files changed, 205 insertions, 0 deletions
diff --git a/src/LocalServers/LocalGridServers/LocalGrid.cs b/src/LocalServers/LocalGridServers/LocalGrid.cs
new file mode 100644
index 0000000..5adce27
--- /dev/null
+++ b/src/LocalServers/LocalGridServers/LocalGrid.cs
@@ -0,0 +1,205 @@
1/*
2* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
3*
4* Redistribution and use in source and binary forms, with or without
5* modification, are permitted provided that the following conditions are met:
6* * Redistributions of source code must retain the above copyright
7* notice, this list of conditions and the following disclaimer.
8* * Redistributions in binary form must reproduce the above copyright
9* notice, this list of conditions and the following disclaimer in the
10* documentation and/or other materials provided with the distribution.
11* * Neither the name of the <organization> nor the
12* names of its contributors may be used to endorse or promote products
13* derived from this software without specific prior written permission.
14*
15* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
16* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
19* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*
26*/
27using System;
28using System.Collections.Generic;
29using System.Threading;
30using OpenSim.GridServers;
31using libsecondlife;
32
33namespace LocalGridServers
34{
35 /// <summary>
36 ///
37 /// </summary>
38 ///
39 public class LocalGridPlugin : IGridPlugin
40 {
41 public LocalGridPlugin()
42 {
43
44 }
45
46 public IGridServer GetGridServer()
47 {
48 return(new LocalGridServer());
49 }
50 }
51
52 public class LocalAssetPlugin : IAssetPlugin
53 {
54 public LocalAssetPlugin()
55 {
56
57 }
58
59 public IAssetServer GetAssetServer()
60 {
61 return(new LocalAssetServer());
62 }
63 }
64
65 public class LocalAssetServer : IAssetServer
66 {
67 private IAssetReceiver _receiver;
68 private BlockingQueue<ARequest> _assetRequests;
69
70 public LocalAssetServer()
71 {
72 this._assetRequests = new BlockingQueue<ARequest>();
73 ServerConsole.MainConsole.Instance.WriteLine("Local Asset Server class created");
74 }
75
76 public void SetReceiver(IAssetReceiver receiver)
77 {
78 this._receiver = receiver;
79 }
80
81 public void RequestAsset(LLUUID assetID, bool isTexture)
82 {
83 ARequest req = new ARequest();
84 req.AssetID = assetID;
85 req.IsTexture = isTexture;
86 //this._assetRequests.Enqueue(req);
87 }
88
89 public void UpdateAsset(AssetBase asset)
90 {
91
92 }
93
94 public void UploadNewAsset(AssetBase asset)
95 {
96
97 }
98
99 public void SetServerInfo(string ServerUrl, string ServerKey)
100 {
101
102 }
103
104 private void RunRequests()
105 {
106 while(true)
107 {
108
109 }
110 }
111 }
112
113 public class LocalGridServer :IGridServer
114 {
115 public List<Login> Sessions = new List<Login>();
116
117 public LocalGridServer()
118 {
119 Sessions = new List<Login>();
120 ServerConsole.MainConsole.Instance.WriteLine("Local Grid Server class created");
121 }
122
123 public bool RequestConnection()
124 {
125 return true;
126 }
127 public AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode)
128 {
129 //we are running local
130 AuthenticateResponse user = new AuthenticateResponse();
131
132 lock(this.Sessions)
133 {
134
135 for(int i = 0; i < Sessions.Count; i++)
136 {
137 if((Sessions[i].Agent == agentID) && (Sessions[i].Session == sessionID))
138 {
139 user.Authorised = true;
140 user.LoginInfo = Sessions[i];
141 }
142 }
143 }
144 return(user);
145 }
146
147 public bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode)
148 {
149 return(true);
150 }
151
152 public UUIDBlock RequestUUIDBlock()
153 {
154 UUIDBlock uuidBlock = new UUIDBlock();
155 return(uuidBlock);
156 }
157
158 public void RequestNeighbours()
159 {
160 return;
161 }
162
163 public void SetServerInfo(string ServerUrl, string ServerKey)
164 {
165
166 }
167 /// <summary>
168 /// used by the local login server to inform us of new sessions
169 /// </summary>
170 /// <param name="session"></param>
171 public void AddNewSession(Login session)
172 {
173 lock(this.Sessions)
174 {
175 this.Sessions.Add(session);
176 }
177 }
178 }
179
180 public class BlockingQueue< T > {
181 private Queue< T > _queue = new Queue< T >();
182 private object _queueSync = new object();
183
184 public void Enqueue(T value)
185 {
186 lock(_queueSync)
187 {
188 _queue.Enqueue(value);
189 Monitor.Pulse(_queueSync);
190 }
191 }
192
193 public T Dequeue()
194 {
195 lock(_queueSync)
196 {
197 if( _queue.Count < 1)
198 Monitor.Wait(_queueSync);
199
200 return _queue.Dequeue();
201 }
202 }
203 }
204
205}