aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/LindenUDP/LLPacketServer.cs
diff options
context:
space:
mode:
authorAdam Frisby2008-05-02 16:41:08 +0000
committerAdam Frisby2008-05-02 16:41:08 +0000
commit29b8c84ceaaeca80bfa9c0bfc8c31e421e39ef71 (patch)
tree848ce119d9b87bc186c20b08cc604de50a872b31 /OpenSim/Region/ClientStack/LindenUDP/LLPacketServer.cs
parent* Refactored ClientView into LLClientView. Removed all direct references to U... (diff)
downloadopensim-SC_OLD-29b8c84ceaaeca80bfa9c0bfc8c31e421e39ef71.zip
opensim-SC_OLD-29b8c84ceaaeca80bfa9c0bfc8c31e421e39ef71.tar.gz
opensim-SC_OLD-29b8c84ceaaeca80bfa9c0bfc8c31e421e39ef71.tar.bz2
opensim-SC_OLD-29b8c84ceaaeca80bfa9c0bfc8c31e421e39ef71.tar.xz
* Commit 2/3 - Please dont attempt to update to this revision until all 3 are in.
Diffstat (limited to 'OpenSim/Region/ClientStack/LindenUDP/LLPacketServer.cs')
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLPacketServer.cs150
1 files changed, 150 insertions, 0 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLPacketServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLPacketServer.cs
new file mode 100644
index 0000000..48afa84
--- /dev/null
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLPacketServer.cs
@@ -0,0 +1,150 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.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.Net;
29using System.Net.Sockets;
30using libsecondlife;
31using libsecondlife.Packets;
32using OpenSim.Framework;
33using OpenSim.Framework.Communications.Cache;
34using OpenSim.Region.ClientStack.LindenUDP;
35
36namespace OpenSim.Region.ClientStack.LindenUDP
37{
38 public class LLPacketServer
39 {
40 //private static readonly log4net.ILog m_log
41 // = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
42
43 private LLClientStackNetworkHandler m_networkHandler;
44 private IScene m_scene;
45
46 //private readonly ClientManager m_clientManager = new ClientManager();
47 //public ClientManager ClientManager
48 //{
49 // get { return m_clientManager; }
50 //}
51
52 public LLPacketServer(LLClientStackNetworkHandler networkHandler)
53 {
54 m_networkHandler = networkHandler;
55 m_networkHandler.RegisterPacketServer(this);
56 }
57
58 public IScene LocalScene
59 {
60 set { m_scene = value; }
61 }
62
63 /// <summary>
64 ///
65 /// </summary>
66 /// <param name="circuitCode"></param>
67 /// <param name="packet"></param>
68 public virtual void InPacket(uint circuitCode, Packet packet)
69 {
70 m_scene.ClientManager.InPacket(circuitCode, packet);
71 }
72
73 protected virtual IClientAPI CreateNewClient(EndPoint remoteEP, UseCircuitCodePacket initialcirpack,
74 ClientManager clientManager, IScene scene, AssetCache assetCache,
75 LLPacketServer packServer, AgentCircuitManager authenSessions,
76 LLUUID agentId, LLUUID sessionId, uint circuitCode, EndPoint proxyEP)
77 {
78 return
79 new LLClientView(remoteEP, scene, assetCache, packServer, authenSessions, agentId, sessionId, circuitCode, proxyEP);
80 }
81
82 public virtual bool AddNewClient(EndPoint epSender, UseCircuitCodePacket useCircuit, AssetCache assetCache,
83 AgentCircuitManager authenticateSessionsClass, EndPoint proxyEP)
84 {
85 IClientAPI newuser;
86
87 if (m_scene.ClientManager.TryGetClient(useCircuit.CircuitCode.Code, out newuser))
88 {
89 return false;
90 }
91 else
92 {
93 newuser = CreateNewClient(epSender, useCircuit, m_scene.ClientManager, m_scene, assetCache, this,
94 authenticateSessionsClass, useCircuit.CircuitCode.ID,
95 useCircuit.CircuitCode.SessionID, useCircuit.CircuitCode.Code, proxyEP);
96
97 m_scene.ClientManager.Add(useCircuit.CircuitCode.Code, newuser);
98
99 newuser.OnViewerEffect += m_scene.ClientManager.ViewerEffectHandler;
100 newuser.OnLogout += LogoutHandler;
101 newuser.OnConnectionClosed += CloseClient;
102
103 return true;
104 }
105 }
106
107 public void LogoutHandler(IClientAPI client)
108 {
109 client.SendLogoutPacket();
110
111 CloseClient(client);
112 }
113
114 /// <summary>
115 ///
116 /// </summary>
117 /// <param name="buffer"></param>
118 /// <param name="size"></param>
119 /// <param name="flags"></param>
120 /// <param name="circuitcode"></param>
121 public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)
122 {
123 m_networkHandler.SendPacketTo(buffer, size, flags, circuitcode);
124 }
125
126 /// <summary>
127 ///
128 /// </summary>
129 /// <param name="circuitcode"></param>
130 public virtual void CloseCircuit(uint circuitcode)
131 {
132 m_networkHandler.RemoveClientCircuit(circuitcode);
133
134 //m_scene.ClientManager.CloseAllAgents(circuitcode);
135 }
136
137 /// <summary>
138 /// Completely close down the given client.
139 /// </summary>
140 /// <param name="client"></param>
141 public virtual void CloseClient(IClientAPI client)
142 {
143 //m_log.Info("PacketServer:CloseClient()");
144
145 CloseCircuit(client.CircuitCode);
146 m_scene.ClientManager.Remove(client.CircuitCode);
147 client.Close(false);
148 }
149 }
150} \ No newline at end of file