aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/PacketServer.cs
diff options
context:
space:
mode:
authorMW2007-06-27 15:28:52 +0000
committerMW2007-06-27 15:28:52 +0000
commit646bbbc84b8010e0dacbeed5342cdb045f46cc49 (patch)
tree770b34d19855363c3c113ab9a0af9a56d821d887 /OpenSim/Region/ClientStack/PacketServer.cs
downloadopensim-SC_OLD-646bbbc84b8010e0dacbeed5342cdb045f46cc49.zip
opensim-SC_OLD-646bbbc84b8010e0dacbeed5342cdb045f46cc49.tar.gz
opensim-SC_OLD-646bbbc84b8010e0dacbeed5342cdb045f46cc49.tar.bz2
opensim-SC_OLD-646bbbc84b8010e0dacbeed5342cdb045f46cc49.tar.xz
Some work on restructuring the namespaces / project names. Note this doesn't compile yet as not all the code has been changed to use the new namespaces. Am committing it now for feedback on the namespaces.
Diffstat (limited to 'OpenSim/Region/ClientStack/PacketServer.cs')
-rw-r--r--OpenSim/Region/ClientStack/PacketServer.cs183
1 files changed, 183 insertions, 0 deletions
diff --git a/OpenSim/Region/ClientStack/PacketServer.cs b/OpenSim/Region/ClientStack/PacketServer.cs
new file mode 100644
index 0000000..229570c
--- /dev/null
+++ b/OpenSim/Region/ClientStack/PacketServer.cs
@@ -0,0 +1,183 @@
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.Generic;
30using System.Text;
31using libsecondlife.Packets;
32using OpenSim.Framework.Interfaces;
33using OpenSim.Framework;
34using System.Net;
35using System.Net.Sockets;
36using OpenSim.Assets;
37using OpenSim.Caches;
38
39namespace OpenSim
40{
41 public class PacketServer
42 {
43 private ClientStackNetworkHandler _networkHandler;
44 private IWorld _localWorld;
45 public Dictionary<uint, ClientView> ClientThreads = new Dictionary<uint, ClientView>();
46 public Dictionary<uint, IClientAPI> ClientAPIs = new Dictionary<uint, IClientAPI>();
47 protected uint serverPort;
48
49 public PacketServer(ClientStackNetworkHandler networkHandler, uint port)
50 {
51 _networkHandler = networkHandler;
52 this.serverPort = port;
53 _networkHandler.RegisterPacketServer(this);
54 }
55
56 public IWorld LocalWorld
57 {
58 set
59 {
60 this._localWorld = value;
61 }
62 }
63
64 /// <summary>
65 ///
66 /// </summary>
67 /// <param name="circuitCode"></param>
68 /// <param name="packet"></param>
69 public virtual void ClientInPacket(uint circuitCode, Packet packet)
70 {
71 if (this.ClientThreads.ContainsKey(circuitCode))
72 {
73 ClientThreads[circuitCode].InPacket(packet);
74 }
75 }
76
77 /// <summary>
78 ///
79 /// </summary>
80 /// <param name="circuitCode"></param>
81 /// <returns></returns>
82 public virtual bool AddNewCircuitCodeClient(uint circuitCode)
83 {
84 return false;
85 }
86
87 /// <summary>
88 ///
89 /// </summary>
90 /// <param name="packet"></param>
91 public virtual void SendPacketToAllClients(Packet packet)
92 {
93
94 }
95
96 /// <summary>
97 ///
98 /// </summary>
99 /// <param name="packet"></param>
100 /// <param name="simClient"></param>
101 public virtual void SendPacketToAllExcept(Packet packet, ClientView simClient)
102 {
103
104 }
105
106 /// <summary>
107 ///
108 /// </summary>
109 /// <param name="packetType"></param>
110 /// <param name="handler"></param>
111 public virtual void AddClientPacketHandler(PacketType packetType, PacketMethod handler)
112 {
113
114 }
115
116 /// <summary>
117 ///
118 /// </summary>
119 public virtual void RegisterClientPacketHandlers()
120 {
121
122 }
123
124 /// <summary>
125 ///
126 /// </summary>
127 /// <param name="remoteEP"></param>
128 /// <param name="initialcirpack"></param>
129 /// <param name="clientThreads"></param>
130 /// <param name="world"></param>
131 /// <param name="assetCache"></param>
132 /// <param name="packServer"></param>
133 /// <param name="inventoryCache"></param>
134 /// <param name="authenSessions"></param>
135 /// <returns></returns>
136 protected virtual ClientView CreateNewClient(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, Dictionary<uint, ClientView> clientThreads, IWorld world, AssetCache assetCache, PacketServer packServer, InventoryCache inventoryCache, AuthenticateSessionsBase authenSessions)
137 {
138 return new ClientView(remoteEP, initialcirpack, clientThreads, world, assetCache, packServer, inventoryCache, authenSessions );
139 }
140
141 /// <summary>
142 ///
143 /// </summary>
144 /// <param name="epSender"></param>
145 /// <param name="useCircuit"></param>
146 /// <param name="assetCache"></param>
147 /// <param name="inventoryCache"></param>
148 /// <param name="authenticateSessionsClass"></param>
149 /// <returns></returns>
150 public virtual bool AddNewClient(EndPoint epSender, UseCircuitCodePacket useCircuit, AssetCache assetCache, InventoryCache inventoryCache, AuthenticateSessionsBase authenticateSessionsClass)
151 {
152 ClientView newuser =
153 CreateNewClient(epSender, useCircuit, ClientThreads, _localWorld, assetCache, this, inventoryCache,
154 authenticateSessionsClass);
155
156 this.ClientThreads.Add(useCircuit.CircuitCode.Code, newuser);
157 this.ClientAPIs.Add(useCircuit.CircuitCode.Code, (IClientAPI)newuser);
158
159 return true;
160 }
161
162 /// <summary>
163 ///
164 /// </summary>
165 /// <param name="buffer"></param>
166 /// <param name="size"></param>
167 /// <param name="flags"></param>
168 /// <param name="circuitcode"></param>
169 public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)
170 {
171 this._networkHandler.SendPacketTo(buffer, size, flags, circuitcode);
172 }
173
174 /// <summary>
175 ///
176 /// </summary>
177 /// <param name="circuitcode"></param>
178 public virtual void RemoveClientCircuit(uint circuitcode)
179 {
180 this._networkHandler.RemoveClientCircuit(circuitcode);
181 }
182 }
183}