aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/OpenSim.RegionServer/ClientView.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/OpenSim.RegionServer/ClientView.cs292
1 files changed, 0 insertions, 292 deletions
diff --git a/OpenSim/OpenSim.RegionServer/ClientView.cs b/OpenSim/OpenSim.RegionServer/ClientView.cs
deleted file mode 100644
index 0693f70..0000000
--- a/OpenSim/OpenSim.RegionServer/ClientView.cs
+++ /dev/null
@@ -1,292 +0,0 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using libsecondlife;
32using libsecondlife.Packets;
33using Nwc.XmlRpc;
34using System.Net;
35using System.Net.Sockets;
36using System.IO;
37using System.Threading;
38using System.Timers;
39using OpenSim.Framework;
40using OpenSim.Framework.Interfaces;
41using OpenSim.Framework.Types;
42using OpenSim.Framework.Inventory;
43using OpenSim.Framework.Utilities;
44using OpenSim.Assets;
45
46namespace OpenSim
47{
48 public delegate bool PacketMethod(ClientView simClient, Packet packet);
49
50 /// <summary>
51 /// Handles new client connections
52 /// Constructor takes a single Packet and authenticates everything
53 /// </summary>
54 public partial class ClientView : ClientViewBase, IClientAPI
55 {
56 public static TerrainManager TerrainManager;
57
58 protected static Dictionary<PacketType, PacketMethod> PacketHandlers = new Dictionary<PacketType, PacketMethod>(); //Global/static handlers for all clients
59 protected Dictionary<PacketType, PacketMethod> m_packetHandlers = new Dictionary<PacketType, PacketMethod>(); //local handlers for this instance
60
61 public LLUUID AgentID;
62 public LLUUID SessionID;
63 public LLUUID SecureSessionID = LLUUID.Zero;
64 public string firstName;
65 public string lastName;
66 public bool m_child = false;
67 private UseCircuitCodePacket cirpack;
68 public Thread ClientThread;
69 public LLVector3 startpos;
70
71 private AgentAssetUpload UploadAssets;
72 private LLUUID newAssetFolder = LLUUID.Zero;
73 private bool debug = false;
74 protected IWorld m_world;
75 private Dictionary<uint, ClientView> m_clientThreads;
76 private AssetCache m_assetCache;
77 private IGridServer m_gridServer;
78 private InventoryCache m_inventoryCache;
79 private int cachedtextureserial = 0;
80 private RegionInfo m_regionData;
81 protected AuthenticateSessionsBase m_authenticateSessionsHandler;
82
83 public ClientView(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, Dictionary<uint, ClientView> clientThreads, IWorld world, AssetCache assetCache, PacketServer packServer, InventoryCache inventoryCache, AuthenticateSessionsBase authenSessions )
84 {
85 m_world = world;
86 m_clientThreads = clientThreads;
87 m_assetCache = assetCache;
88
89 m_networkServer = packServer;
90 m_inventoryCache = inventoryCache;
91 m_authenticateSessionsHandler = authenSessions;
92
93 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "OpenSimClient.cs - Started up new client thread to handle incoming request");
94 cirpack = initialcirpack;
95 userEP = remoteEP;
96
97 this.m_child = m_authenticateSessionsHandler.GetAgentChildStatus(initialcirpack.CircuitCode.Code);
98 this.startpos = m_authenticateSessionsHandler.GetPosition(initialcirpack.CircuitCode.Code);
99
100 PacketQueue = new BlockingQueue<QueItem>();
101
102 this.UploadAssets = new AgentAssetUpload(this, m_assetCache, m_inventoryCache);
103 AckTimer = new System.Timers.Timer(500);
104 AckTimer.Elapsed += new ElapsedEventHandler(AckTimer_Elapsed);
105 AckTimer.Start();
106
107 this.RegisterLocalPacketHandlers();
108
109 ClientThread = new Thread(new ThreadStart(AuthUser));
110 ClientThread.IsBackground = true;
111 ClientThread.Start();
112 }
113
114 # region Client Methods
115 public void UpgradeClient()
116 {
117 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "SimClient.cs:UpgradeClient() - upgrading child to full agent");
118 this.m_child = false;
119 this.startpos = m_authenticateSessionsHandler.GetPosition(CircuitCode);
120 m_authenticateSessionsHandler.UpdateAgentChildStatus(CircuitCode, false);
121 OnChildAgentStatus(this.m_child);
122 }
123
124 public void DowngradeClient()
125 {
126 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "SimClient.cs:UpgradeClient() - changing full agent to child");
127 this.m_child = true;
128 OnChildAgentStatus(this.m_child);
129
130 }
131
132 public void KillClient()
133 {
134 KillObjectPacket kill = new KillObjectPacket();
135 kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1];
136 kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock();
137 //kill.ObjectData[0].ID = this.ClientAvatar.localid;
138 foreach (ClientView client in m_clientThreads.Values)
139 {
140 client.OutPacket(kill);
141 }
142
143 this.m_inventoryCache.ClientLeaving(this.AgentID, null);
144
145
146 // m_world.RemoveViewerAgent(this);
147
148 m_clientThreads.Remove(this.CircuitCode);
149 m_networkServer.RemoveClientCircuit(this.CircuitCode);
150 this.ClientThread.Abort();
151 }
152 #endregion
153
154 # region Packet Handling
155 public static bool AddPacketHandler(PacketType packetType, PacketMethod handler)
156 {
157 bool result = false;
158 lock (PacketHandlers)
159 {
160 if (!PacketHandlers.ContainsKey(packetType))
161 {
162 PacketHandlers.Add(packetType, handler);
163 result = true;
164 }
165 }
166 return result;
167 }
168
169 public bool AddLocalPacketHandler(PacketType packetType, PacketMethod handler)
170 {
171 bool result = false;
172 lock (m_packetHandlers)
173 {
174 if (!m_packetHandlers.ContainsKey(packetType))
175 {
176 m_packetHandlers.Add(packetType, handler);
177 result = true;
178 }
179 }
180 return result;
181 }
182
183 protected virtual bool ProcessPacketMethod(Packet packet)
184 {
185 bool result = false;
186 bool found = false;
187 PacketMethod method;
188 if (m_packetHandlers.TryGetValue(packet.Type, out method))
189 {
190 //there is a local handler for this packet type
191 result = method(this, packet);
192 }
193 else
194 {
195 //there is not a local handler so see if there is a Global handler
196 lock (PacketHandlers)
197 {
198 found = PacketHandlers.TryGetValue(packet.Type, out method);
199 }
200 if (found)
201 {
202 result = method(this, packet);
203 }
204 }
205 return result;
206 }
207
208 protected virtual void ClientLoop()
209 {
210 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "OpenSimClient.cs:ClientLoop() - Entered loop");
211 while (true)
212 {
213 QueItem nextPacket = PacketQueue.Dequeue();
214 if (nextPacket.Incoming)
215 {
216 //is a incoming packet
217 ProcessInPacket(nextPacket.Packet);
218 }
219 else
220 {
221 //is a out going packet
222 ProcessOutPacket(nextPacket.Packet);
223 }
224 }
225 }
226 # endregion
227
228 # region Setup
229
230 protected virtual void InitNewClient()
231 {
232 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "OpenSimClient.cs:InitNewClient() - Adding viewer agent to world");
233 this.m_world.AddNewAvatar(this, this.AgentID, false);
234 }
235
236 protected virtual void AuthUser()
237 {
238 // AuthenticateResponse sessionInfo = m_gridServer.AuthenticateSession(cirpack.CircuitCode.SessionID, cirpack.CircuitCode.ID, cirpack.CircuitCode.Code);
239 AuthenticateResponse sessionInfo = this.m_authenticateSessionsHandler.AuthenticateSession(cirpack.CircuitCode.SessionID, cirpack.CircuitCode.ID, cirpack.CircuitCode.Code);
240 if (!sessionInfo.Authorised)
241 {
242 //session/circuit not authorised
243 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.NORMAL, "OpenSimClient.cs:AuthUser() - New user request denied to " + userEP.ToString());
244 ClientThread.Abort();
245 }
246 else
247 {
248 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.NORMAL, "OpenSimClient.cs:AuthUser() - Got authenticated connection from " + userEP.ToString());
249 //session is authorised
250 this.AgentID = cirpack.CircuitCode.ID;
251 this.SessionID = cirpack.CircuitCode.SessionID;
252 this.CircuitCode = cirpack.CircuitCode.Code;
253 this.firstName = sessionInfo.LoginInfo.First;
254 this.lastName = sessionInfo.LoginInfo.Last;
255
256 if (sessionInfo.LoginInfo.SecureSession != LLUUID.Zero)
257 {
258 this.SecureSessionID = sessionInfo.LoginInfo.SecureSession;
259 }
260 InitNewClient();
261
262 ClientLoop();
263 }
264 }
265 # endregion
266
267
268 protected override void KillThread()
269 {
270 this.ClientThread.Abort();
271 }
272
273 #region Inventory Creation
274 private void SetupInventory(AuthenticateResponse sessionInfo)
275 {
276
277 }
278 private AgentInventory CreateInventory(LLUUID baseFolder)
279 {
280 AgentInventory inventory = null;
281
282 return inventory;
283 }
284
285 private void CreateInventoryItem(CreateInventoryItemPacket packet)
286 {
287
288 }
289 #endregion
290
291 }
292}