diff options
author | Adam Frisby | 2007-07-11 08:10:25 +0000 |
---|---|---|
committer | Adam Frisby | 2007-07-11 08:10:25 +0000 |
commit | e2ff441e31328e60c8bb1d4bb32fa4ac64f91978 (patch) | |
tree | 8405b6cef57b66a58f31a24c859846085d0b81f7 /OpenSim/Region/ClientStack/PacketServer.cs | |
parent | * Wiping trunk in prep for Sugilite (diff) | |
parent | * Applying dalien's patches from bug#177 and #179 (diff) | |
download | opensim-SC_OLD-e2ff441e31328e60c8bb1d4bb32fa4ac64f91978.zip opensim-SC_OLD-e2ff441e31328e60c8bb1d4bb32fa4ac64f91978.tar.gz opensim-SC_OLD-e2ff441e31328e60c8bb1d4bb32fa4ac64f91978.tar.bz2 opensim-SC_OLD-e2ff441e31328e60c8bb1d4bb32fa4ac64f91978.tar.xz |
* Bringing Sugilite in to trunk
Diffstat (limited to 'OpenSim/Region/ClientStack/PacketServer.cs')
-rw-r--r-- | OpenSim/Region/ClientStack/PacketServer.cs | 184 |
1 files changed, 184 insertions, 0 deletions
diff --git a/OpenSim/Region/ClientStack/PacketServer.cs b/OpenSim/Region/ClientStack/PacketServer.cs new file mode 100644 index 0000000..a88c682 --- /dev/null +++ b/OpenSim/Region/ClientStack/PacketServer.cs | |||
@@ -0,0 +1,184 @@ | |||
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 | */ | ||
28 | using System.Collections.Generic; | ||
29 | using System.Net; | ||
30 | using System.Net.Sockets; | ||
31 | using libsecondlife.Packets; | ||
32 | using OpenSim.Assets; | ||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Framework.Interfaces; | ||
35 | using OpenSim.Region.Caches; | ||
36 | |||
37 | namespace OpenSim.Region.ClientStack | ||
38 | { | ||
39 | public class PacketServer | ||
40 | { | ||
41 | private ClientStackNetworkHandler _networkHandler; | ||
42 | private IWorld _localWorld; | ||
43 | public Dictionary<uint, ClientView> ClientThreads = new Dictionary<uint, ClientView>(); | ||
44 | private ClientManager m_clientManager = new ClientManager(); | ||
45 | public ClientManager ClientManager | ||
46 | { | ||
47 | get { return m_clientManager; } | ||
48 | } | ||
49 | |||
50 | public PacketServer(ClientStackNetworkHandler networkHandler) | ||
51 | { | ||
52 | _networkHandler = networkHandler; | ||
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.m_clientManager.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 | this.m_clientManager.Remove(circuitcode); | ||
182 | } | ||
183 | } | ||
184 | } | ||