aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/UDPServer.cs
diff options
context:
space:
mode:
authorlbsa712007-10-30 09:05:31 +0000
committerlbsa712007-10-30 09:05:31 +0000
commit67e12b95ea7b68f4904a7484d77ecfd787d16d0c (patch)
tree20b00d24c8a7617017960432ec044852e3ad5fa9 /OpenSim/Region/ClientStack/UDPServer.cs
parent* Deleted .user file (diff)
downloadopensim-SC_OLD-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.zip
opensim-SC_OLD-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.tar.gz
opensim-SC_OLD-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.tar.bz2
opensim-SC_OLD-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.tar.xz
* Optimized usings
* Shortened type references * Removed redundant 'this' qualifier
Diffstat (limited to 'OpenSim/Region/ClientStack/UDPServer.cs')
-rw-r--r--OpenSim/Region/ClientStack/UDPServer.cs60
1 files changed, 25 insertions, 35 deletions
diff --git a/OpenSim/Region/ClientStack/UDPServer.cs b/OpenSim/Region/ClientStack/UDPServer.cs
index 584b80c..e5965cb 100644
--- a/OpenSim/Region/ClientStack/UDPServer.cs
+++ b/OpenSim/Region/ClientStack/UDPServer.cs
@@ -32,13 +32,10 @@ using System.Net.Sockets;
32using libsecondlife.Packets; 32using libsecondlife.Packets;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Communications.Cache; 34using OpenSim.Framework.Communications.Cache;
35using OpenSim.Framework;
36using OpenSim.Framework.Console; 35using OpenSim.Framework.Console;
37using OpenSim.Framework.Interfaces;
38 36
39namespace OpenSim.Region.ClientStack 37namespace OpenSim.Region.ClientStack
40{ 38{
41
42 public class UDPServer : ClientStackNetworkHandler 39 public class UDPServer : ClientStackNetworkHandler
43 { 40 {
44 protected Dictionary<EndPoint, uint> clientCircuits = new Dictionary<EndPoint, uint>(); 41 protected Dictionary<EndPoint, uint> clientCircuits = new Dictionary<EndPoint, uint>();
@@ -59,22 +56,16 @@ namespace OpenSim.Region.ClientStack
59 56
60 public PacketServer PacketServer 57 public PacketServer PacketServer
61 { 58 {
62 get 59 get { return m_packetServer; }
63 { 60 set { m_packetServer = value; }
64 return m_packetServer;
65 }
66 set
67 {
68 m_packetServer = value;
69 }
70 } 61 }
71 62
72 public IScene LocalScene 63 public IScene LocalScene
73 { 64 {
74 set 65 set
75 { 66 {
76 this.m_localScene = value; 67 m_localScene = value;
77 this.m_packetServer.LocalScene = this.m_localScene; 68 m_packetServer.LocalScene = m_localScene;
78 } 69 }
79 } 70 }
80 71
@@ -85,10 +76,10 @@ namespace OpenSim.Region.ClientStack
85 public UDPServer(int port, AssetCache assetCache, LogBase console, AgentCircuitManager authenticateClass) 76 public UDPServer(int port, AssetCache assetCache, LogBase console, AgentCircuitManager authenticateClass)
86 { 77 {
87 listenPort = port; 78 listenPort = port;
88 this.m_assetCache = assetCache; 79 m_assetCache = assetCache;
89 this.m_log = console; 80 m_log = console;
90 this.m_authenticateSessionsClass = authenticateClass; 81 m_authenticateSessionsClass = authenticateClass;
91 this.CreatePacketServer(); 82 CreatePacketServer();
92 } 83 }
93 84
94 protected virtual void CreatePacketServer() 85 protected virtual void CreatePacketServer()
@@ -99,7 +90,7 @@ namespace OpenSim.Region.ClientStack
99 protected virtual void OnReceivedData(IAsyncResult result) 90 protected virtual void OnReceivedData(IAsyncResult result)
100 { 91 {
101 ipeSender = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0); 92 ipeSender = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0);
102 epSender = (EndPoint)ipeSender; 93 epSender = (EndPoint) ipeSender;
103 Packet packet = null; 94 Packet packet = null;
104 95
105 int numBytes; 96 int numBytes;
@@ -108,7 +99,7 @@ namespace OpenSim.Region.ClientStack
108 { 99 {
109 numBytes = Server.EndReceiveFrom(result, ref epSender); 100 numBytes = Server.EndReceiveFrom(result, ref epSender);
110 } 101 }
111 catch (System.Net.Sockets.SocketException e) 102 catch (SocketException e)
112 { 103 {
113 // TODO : Actually only handle those states that we have control over, re-throw everything else, 104 // TODO : Actually only handle those states that we have control over, re-throw everything else,
114 // TODO: implement cases as we encounter them. 105 // TODO: implement cases as we encounter them.
@@ -134,7 +125,7 @@ namespace OpenSim.Region.ClientStack
134 if (clientCircuits.TryGetValue(epSender, out circuit)) 125 if (clientCircuits.TryGetValue(epSender, out circuit))
135 { 126 {
136 //if so then send packet to the packetserver 127 //if so then send packet to the packetserver
137 this.m_packetServer.InPacket(circuit, packet); 128 m_packetServer.InPacket(circuit, packet);
138 } 129 }
139 else if (packet.Type == PacketType.UseCircuitCode) 130 else if (packet.Type == PacketType.UseCircuitCode)
140 { 131 {
@@ -142,7 +133,8 @@ namespace OpenSim.Region.ClientStack
142 AddNewClient(packet); 133 AddNewClient(packet);
143 } 134 }
144 else 135 else
145 { // invalid client 136 {
137 // invalid client
146 m_log.Warn("client", "Got a packet from an invalid client - " + epSender.ToString()); 138 m_log.Warn("client", "Got a packet from an invalid client - " + epSender.ToString());
147 } 139 }
148 140
@@ -160,10 +152,10 @@ namespace OpenSim.Region.ClientStack
160 152
161 protected virtual void AddNewClient(Packet packet) 153 protected virtual void AddNewClient(Packet packet)
162 { 154 {
163 UseCircuitCodePacket useCircuit = (UseCircuitCodePacket)packet; 155 UseCircuitCodePacket useCircuit = (UseCircuitCodePacket) packet;
164 this.clientCircuits.Add(epSender, useCircuit.CircuitCode.Code); 156 clientCircuits.Add(epSender, useCircuit.CircuitCode.Code);
165 157
166 this.PacketServer.AddNewClient(epSender, useCircuit, m_assetCache, m_authenticateSessionsClass); 158 PacketServer.AddNewClient(epSender, useCircuit, m_assetCache, m_authenticateSessionsClass);
167 } 159 }
168 160
169 public void ServerListener() 161 public void ServerListener()
@@ -177,24 +169,24 @@ namespace OpenSim.Region.ClientStack
177 m_log.Verbose("SERVER", "UDP socket bound, getting ready to listen"); 169 m_log.Verbose("SERVER", "UDP socket bound, getting ready to listen");
178 170
179 ipeSender = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0); 171 ipeSender = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0);
180 epSender = (EndPoint)ipeSender; 172 epSender = (EndPoint) ipeSender;
181 ReceivedData = new AsyncCallback(this.OnReceivedData); 173 ReceivedData = new AsyncCallback(OnReceivedData);
182 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); 174 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
183 175
184 m_log.Status("SERVER", "Listening..."); 176 m_log.Status("SERVER", "Listening...");
185
186 } 177 }
187 178
188 public virtual void RegisterPacketServer(PacketServer server) 179 public virtual void RegisterPacketServer(PacketServer server)
189 { 180 {
190 this.m_packetServer = server; 181 m_packetServer = server;
191 } 182 }
192 183
193 public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)//EndPoint packetSender) 184 public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)
185 //EndPoint packetSender)
194 { 186 {
195 // find the endpoint for this circuit 187 // find the endpoint for this circuit
196 EndPoint sendto = null; 188 EndPoint sendto = null;
197 foreach (KeyValuePair<EndPoint, uint> p in this.clientCircuits) 189 foreach (KeyValuePair<EndPoint, uint> p in clientCircuits)
198 { 190 {
199 if (p.Value == circuitcode) 191 if (p.Value == circuitcode)
200 { 192 {
@@ -205,22 +197,20 @@ namespace OpenSim.Region.ClientStack
205 if (sendto != null) 197 if (sendto != null)
206 { 198 {
207 //we found the endpoint so send the packet to it 199 //we found the endpoint so send the packet to it
208 this.Server.SendTo(buffer, size, flags, sendto); 200 Server.SendTo(buffer, size, flags, sendto);
209 } 201 }
210 } 202 }
211 203
212 public virtual void RemoveClientCircuit(uint circuitcode) 204 public virtual void RemoveClientCircuit(uint circuitcode)
213 { 205 {
214 foreach (KeyValuePair<EndPoint, uint> p in this.clientCircuits) 206 foreach (KeyValuePair<EndPoint, uint> p in clientCircuits)
215 { 207 {
216 if (p.Value == circuitcode) 208 if (p.Value == circuitcode)
217 { 209 {
218 this.clientCircuits.Remove(p.Key); 210 clientCircuits.Remove(p.Key);
219 break; 211 break;
220 } 212 }
221 } 213 }
222 } 214 }
223
224
225 } 215 }
226} \ No newline at end of file 216} \ No newline at end of file