aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack
diff options
context:
space:
mode:
authorJohan Berntsson2008-03-04 05:31:54 +0000
committerJohan Berntsson2008-03-04 05:31:54 +0000
commit279e0061c515ee0a03036bef68eea9738273d785 (patch)
tree4502228eb7b87a760e0b0e67aded9d1d870d0bed /OpenSim/Region/ClientStack
parentAdded copyright heaaders. Minor cleanup. (diff)
downloadopensim-SC-279e0061c515ee0a03036bef68eea9738273d785.zip
opensim-SC-279e0061c515ee0a03036bef68eea9738273d785.tar.gz
opensim-SC-279e0061c515ee0a03036bef68eea9738273d785.tar.bz2
opensim-SC-279e0061c515ee0a03036bef68eea9738273d785.tar.xz
Merged 3Di code that provides scene and avatar serialization, and plugin support for region move/split/merge. See ThirdParty/3Di/README.txt. Unless the new modules are used there should be no noticeable changes when running OpenSim.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ClientStack/ClientView.cs145
-rw-r--r--OpenSim/Region/ClientStack/PacketQueue.cs12
-rw-r--r--OpenSim/Region/ClientStack/PacketServer.cs8
-rw-r--r--OpenSim/Region/ClientStack/RegionApplicationBase.cs11
-rw-r--r--OpenSim/Region/ClientStack/UDPServer.cs92
5 files changed, 248 insertions, 20 deletions
diff --git a/OpenSim/Region/ClientStack/ClientView.cs b/OpenSim/Region/ClientStack/ClientView.cs
index b719086..b5cd6fb 100644
--- a/OpenSim/Region/ClientStack/ClientView.cs
+++ b/OpenSim/Region/ClientStack/ClientView.cs
@@ -61,6 +61,8 @@ namespace OpenSim.Region.ClientStack
61 /* static variables */ 61 /* static variables */
62 public static TerrainManager TerrainManager; 62 public static TerrainManager TerrainManager;
63 63
64 public delegate bool SynchronizeClientHandler(IScene scene, Packet packet, LLUUID agentID, ThrottleOutPacketType throttlePacketType);
65 public static SynchronizeClientHandler SynchronizeClient = null;
64 /* private variables */ 66 /* private variables */
65 private readonly LLUUID m_sessionId; 67 private readonly LLUUID m_sessionId;
66 private LLUUID m_secureSessionId = LLUUID.Zero; 68 private LLUUID m_secureSessionId = LLUUID.Zero;
@@ -118,6 +120,7 @@ namespace OpenSim.Region.ClientStack
118 protected Thread m_clientThread; 120 protected Thread m_clientThread;
119 protected LLVector3 m_startpos; 121 protected LLVector3 m_startpos;
120 protected EndPoint m_userEndPoint; 122 protected EndPoint m_userEndPoint;
123 protected EndPoint m_proxyEndPoint;
121 124
122 /* Instantiated Designated Event Delegates */ 125 /* Instantiated Designated Event Delegates */
123 //- used so we don't create new objects for each incoming packet and then toss it out later */ 126 //- used so we don't create new objects for each incoming packet and then toss it out later */
@@ -291,7 +294,7 @@ namespace OpenSim.Region.ClientStack
291 /* METHODS */ 294 /* METHODS */
292 295
293 public ClientView(EndPoint remoteEP, IScene scene, AssetCache assetCache, PacketServer packServer, 296 public ClientView(EndPoint remoteEP, IScene scene, AssetCache assetCache, PacketServer packServer,
294 AgentCircuitManager authenSessions, LLUUID agentId, LLUUID sessionId, uint circuitCode) 297 AgentCircuitManager authenSessions, LLUUID agentId, LLUUID sessionId, uint circuitCode, EndPoint proxyEP)
295 { 298 {
296 m_moneyBalance = 1000; 299 m_moneyBalance = 1000;
297 300
@@ -311,6 +314,7 @@ namespace OpenSim.Region.ClientStack
311 m_circuitCode = circuitCode; 314 m_circuitCode = circuitCode;
312 315
313 m_userEndPoint = remoteEP; 316 m_userEndPoint = remoteEP;
317 m_proxyEndPoint = proxyEP;
314 318
315 m_startpos = m_authenticateSessionsHandler.GetPosition(circuitCode); 319 m_startpos = m_authenticateSessionsHandler.GetPosition(circuitCode);
316 320
@@ -411,7 +415,37 @@ namespace OpenSim.Region.ClientStack
411 415
412 public void Stop() 416 public void Stop()
413 { 417 {
414 m_log.Info("[BUG]: Stop called, please find out where and remove it"); 418 // Shut down timers
419 m_ackTimer.Stop();
420 m_clientPingTimer.Stop();
421 }
422
423 public void Restart()
424 {
425 // re-construct
426 m_pendingAcks = new Dictionary<uint, uint>();
427 m_needAck = new Dictionary<uint, Packet>();
428 m_sequence += 1000000;
429
430 m_ackTimer = new Timer(750);
431 m_ackTimer.Elapsed += new ElapsedEventHandler(AckTimer_Elapsed);
432 m_ackTimer.Start();
433
434 m_clientPingTimer = new Timer(5000);
435 m_clientPingTimer.Elapsed += new ElapsedEventHandler(CheckClientConnectivity);
436 m_clientPingTimer.Enabled = true;
437 }
438
439 public void Terminate()
440 {
441 // disable blocking queue
442 m_packetQueue.Enqueue(null);
443
444 // wait for thread stoped
445 m_clientThread.Join();
446
447 // delete circuit code
448 m_networkServer.CloseClient(this);
415 } 449 }
416 450
417 #endregion 451 #endregion
@@ -507,6 +541,10 @@ namespace OpenSim.Region.ClientStack
507 while (true) 541 while (true)
508 { 542 {
509 QueItem nextPacket = m_packetQueue.Dequeue(); 543 QueItem nextPacket = m_packetQueue.Dequeue();
544 if (nextPacket == null)
545 {
546 break;
547 }
510 if (nextPacket.Incoming) 548 if (nextPacket.Incoming)
511 { 549 {
512 if (nextPacket.Packet.Type != PacketType.AgentUpdate) 550 if (nextPacket.Packet.Type != PacketType.AgentUpdate)
@@ -2642,7 +2680,7 @@ namespace OpenSim.Region.ClientStack
2642 try 2680 try
2643 { 2681 {
2644 byte[] sendbuffer = Pack.ToBytes(); 2682 byte[] sendbuffer = Pack.ToBytes();
2645 PacketPool.Instance.ReturnPacket(Pack); 2683 PacketPool.Instance.ReturnPacket(Pack);
2646 2684
2647 if (Pack.Header.Zerocoded) 2685 if (Pack.Header.Zerocoded)
2648 { 2686 {
@@ -2651,8 +2689,11 @@ namespace OpenSim.Region.ClientStack
2651 } 2689 }
2652 else 2690 else
2653 { 2691 {
2654 m_networkServer.SendPacketTo(sendbuffer, sendbuffer.Length, SocketFlags.None, m_circuitCode); 2692 //Need some extra space in case we need to add proxy information to the message later
2693 Buffer.BlockCopy(sendbuffer, 0, ZeroOutBuffer, 0, sendbuffer.Length);
2694 m_networkServer.SendPacketTo(ZeroOutBuffer, sendbuffer.Length, SocketFlags.None, m_circuitCode);
2655 } 2695 }
2696
2656 } 2697 }
2657 catch (Exception e) 2698 catch (Exception e)
2658 { 2699 {
@@ -2666,6 +2707,12 @@ namespace OpenSim.Region.ClientStack
2666 2707
2667 public virtual void InPacket(Packet NewPack) 2708 public virtual void InPacket(Packet NewPack)
2668 { 2709 {
2710 if(!m_packetProcessingEnabled && NewPack.Type != PacketType.LogoutRequest)
2711 {
2712 PacketPool.Instance.ReturnPacket(NewPack);
2713 return;
2714 }
2715
2669 // Handle appended ACKs 2716 // Handle appended ACKs
2670 if (NewPack != null) 2717 if (NewPack != null)
2671 { 2718 {
@@ -2726,6 +2773,15 @@ namespace OpenSim.Region.ClientStack
2726 2773
2727 public virtual void OutPacket(Packet NewPack, ThrottleOutPacketType throttlePacketType) 2774 public virtual void OutPacket(Packet NewPack, ThrottleOutPacketType throttlePacketType)
2728 { 2775 {
2776 if ((SynchronizeClient != null) && (!PacketProcessingEnabled))
2777 {
2778 // Sending packet to active client's server.
2779 if (SynchronizeClient(m_scene, NewPack, m_agentId, throttlePacketType))
2780 {
2781 return;
2782 }
2783 }
2784
2729 QueItem item = new QueItem(); 2785 QueItem item = new QueItem();
2730 item.Packet = NewPack; 2786 item.Packet = NewPack;
2731 item.Incoming = false; 2787 item.Incoming = false;
@@ -2853,6 +2909,13 @@ namespace OpenSim.Region.ClientStack
2853 } 2909 }
2854 } 2910 }
2855 2911
2912 private bool m_packetProcessingEnabled = true;
2913
2914 public bool PacketProcessingEnabled {
2915 get { return m_packetProcessingEnabled; }
2916 set { m_packetProcessingEnabled = value; }
2917 }
2918
2856 protected void ProcessInPacket(Packet Pack) 2919 protected void ProcessInPacket(Packet Pack)
2857 { 2920 {
2858 ack_pack(Pack); 2921 ack_pack(Pack);
@@ -4373,5 +4436,79 @@ namespace OpenSim.Region.ClientStack
4373 4436
4374 OutPacket(logReply, ThrottleOutPacketType.Task); 4437 OutPacket(logReply, ThrottleOutPacketType.Task);
4375 } 4438 }
4439
4440 public ClientInfo GetClientInfo()
4441 {
4442 //MainLog.Instance.Verbose("CLIENT", "GetClientInfo BGN");
4443
4444 ClientInfo info = new ClientInfo();
4445 info.userEP = this.m_userEndPoint;
4446 info.proxyEP = this.m_proxyEndPoint;
4447 info.agentcircuit = new sAgentCircuitData(RequestClientInfo());
4448
4449 info.pendingAcks = m_pendingAcks;
4450
4451 info.needAck = new Dictionary<uint,byte[]>();
4452
4453 lock (m_needAck)
4454 {
4455 foreach (uint key in m_needAck.Keys)
4456 {
4457 info.needAck.Add(key, m_needAck[key].ToBytes());
4458 }
4459 }
4460
4461/* pending
4462 QueItem[] queitems = m_packetQueue.GetQueueArray();
4463
4464 MainLog.Instance.Verbose("CLIENT", "Queue Count : [{0}]", queitems.Length);
4465
4466 for (int i = 0; i < queitems.Length; i++)
4467 {
4468 if (queitems[i].Incoming == false)
4469 {
4470 info.out_packets.Add(queitems[i].Packet.ToBytes());
4471 MainLog.Instance.Verbose("CLIENT", "Add OutPacket [{0}]", queitems[i].Packet.Type.ToString());
4472 }
4473 }
4474*/
4475
4476 info.sequence = m_sequence;
4477
4478 //MainLog.Instance.Verbose("CLIENT", "GetClientInfo END");
4479
4480 return info;
4481 }
4482
4483 public void SetClientInfo(ClientInfo info)
4484 {
4485 m_pendingAcks = info.pendingAcks;
4486
4487 m_needAck = new Dictionary<uint,Packet>();
4488
4489 Packet packet = null;
4490 int packetEnd = 0;
4491 byte[] zero = new byte[3000];
4492
4493 foreach (uint key in info.needAck.Keys)
4494 {
4495 byte[] buff = info.needAck[key];
4496
4497 packetEnd = buff.Length - 1;
4498
4499 try
4500 {
4501 packet = PacketPool.Instance.GetPacket(buff, ref packetEnd, zero);
4502 }
4503 catch (Exception)
4504 {
4505 //MainLog.Instance.Debug("UDPSERVER", e.ToString());
4506 }
4507
4508 m_needAck.Add(key, packet);
4509 }
4510
4511 m_sequence = info.sequence;
4512 }
4376 } 4513 }
4377} 4514}
diff --git a/OpenSim/Region/ClientStack/PacketQueue.cs b/OpenSim/Region/ClientStack/PacketQueue.cs
index a04828f..82f96e8 100644
--- a/OpenSim/Region/ClientStack/PacketQueue.cs
+++ b/OpenSim/Region/ClientStack/PacketQueue.cs
@@ -142,8 +142,13 @@ namespace OpenSim.Region.ClientStack
142 // We could micro lock, but that will tend to actually 142 // We could micro lock, but that will tend to actually
143 // probably be worse than just synchronizing on SendQueue 143 // probably be worse than just synchronizing on SendQueue
144 144
145 lock (this) 145 if (item == null)
146 { 146 {
147 SendQueue.Enqueue(item);
148 return;
149 }
150
151 lock (this) {
147 switch (item.throttleType) 152 switch (item.throttleType)
148 { 153 {
149 case ThrottleOutPacketType.Resend: 154 case ThrottleOutPacketType.Resend:
@@ -518,5 +523,10 @@ namespace OpenSim.Region.ClientStack
518 TextureOutgoingPacketQueue.Count, 523 TextureOutgoingPacketQueue.Count,
519 AssetOutgoingPacketQueue.Count); 524 AssetOutgoingPacketQueue.Count);
520 } 525 }
526
527 public QueItem[] GetQueueArray()
528 {
529 return SendQueue.GetQueueArray();
530 }
521 } 531 }
522} 532}
diff --git a/OpenSim/Region/ClientStack/PacketServer.cs b/OpenSim/Region/ClientStack/PacketServer.cs
index 250b90a..02ae79b 100644
--- a/OpenSim/Region/ClientStack/PacketServer.cs
+++ b/OpenSim/Region/ClientStack/PacketServer.cs
@@ -74,14 +74,14 @@ namespace OpenSim.Region.ClientStack
74 protected virtual IClientAPI CreateNewClient(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, 74 protected virtual IClientAPI CreateNewClient(EndPoint remoteEP, UseCircuitCodePacket initialcirpack,
75 ClientManager clientManager, IScene scene, AssetCache assetCache, 75 ClientManager clientManager, IScene scene, AssetCache assetCache,
76 PacketServer packServer, AgentCircuitManager authenSessions, 76 PacketServer packServer, AgentCircuitManager authenSessions,
77 LLUUID agentId, LLUUID sessionId, uint circuitCode) 77 LLUUID agentId, LLUUID sessionId, uint circuitCode, EndPoint proxyEP)
78 { 78 {
79 return 79 return
80 new ClientView(remoteEP, scene, assetCache, packServer, authenSessions, agentId, sessionId, circuitCode); 80 new ClientView(remoteEP, scene, assetCache, packServer, authenSessions, agentId, sessionId, circuitCode, proxyEP);
81 } 81 }
82 82
83 public virtual bool AddNewClient(EndPoint epSender, UseCircuitCodePacket useCircuit, AssetCache assetCache, 83 public virtual bool AddNewClient(EndPoint epSender, UseCircuitCodePacket useCircuit, AssetCache assetCache,
84 AgentCircuitManager authenticateSessionsClass) 84 AgentCircuitManager authenticateSessionsClass, EndPoint proxyEP)
85 { 85 {
86 IClientAPI newuser; 86 IClientAPI newuser;
87 87
@@ -93,7 +93,7 @@ namespace OpenSim.Region.ClientStack
93 { 93 {
94 newuser = CreateNewClient(epSender, useCircuit, m_scene.ClientManager, m_scene, assetCache, this, 94 newuser = CreateNewClient(epSender, useCircuit, m_scene.ClientManager, m_scene, assetCache, this,
95 authenticateSessionsClass, useCircuit.CircuitCode.ID, 95 authenticateSessionsClass, useCircuit.CircuitCode.ID,
96 useCircuit.CircuitCode.SessionID, useCircuit.CircuitCode.Code); 96 useCircuit.CircuitCode.SessionID, useCircuit.CircuitCode.Code, proxyEP);
97 97
98 m_scene.ClientManager.Add(useCircuit.CircuitCode.Code, newuser); 98 m_scene.ClientManager.Add(useCircuit.CircuitCode.Code, newuser);
99 99
diff --git a/OpenSim/Region/ClientStack/RegionApplicationBase.cs b/OpenSim/Region/ClientStack/RegionApplicationBase.cs
index a760712..660c3b3 100644
--- a/OpenSim/Region/ClientStack/RegionApplicationBase.cs
+++ b/OpenSim/Region/ClientStack/RegionApplicationBase.cs
@@ -104,13 +104,18 @@ namespace OpenSim.Region.ClientStack
104 104
105 protected Scene SetupScene(RegionInfo regionInfo, out UDPServer udpServer, bool m_permissions) 105 protected Scene SetupScene(RegionInfo regionInfo, out UDPServer udpServer, bool m_permissions)
106 { 106 {
107 return SetupScene(regionInfo, 0, out udpServer, m_permissions);
108 }
109
110 protected Scene SetupScene(RegionInfo regionInfo, int proxyOffset, out UDPServer udpServer, bool m_permissions)
111 {
107 AgentCircuitManager circuitManager = new AgentCircuitManager(); 112 AgentCircuitManager circuitManager = new AgentCircuitManager();
108 IPAddress listenIP = regionInfo.InternalEndPoint.Address; 113 IPAddress listenIP = regionInfo.InternalEndPoint.Address;
109 //if (!IPAddress.TryParse(regionInfo.InternalEndPoint, out listenIP)) 114 //if (!IPAddress.TryParse(regionInfo.InternalEndPoint, out listenIP))
110 // listenIP = IPAddress.Parse("0.0.0.0"); 115 // listenIP = IPAddress.Parse("0.0.0.0");
111 116
112 uint port = (uint) regionInfo.InternalEndPoint.Port; 117 uint port = (uint) regionInfo.InternalEndPoint.Port;
113 udpServer = new UDPServer(listenIP, ref port, regionInfo.m_allow_alternate_ports, m_assetCache, circuitManager); 118 udpServer = new UDPServer(listenIP, ref port, proxyOffset, regionInfo.m_allow_alternate_ports, m_assetCache, circuitManager);
114 regionInfo.InternalEndPoint.Port = (int)port; 119 regionInfo.InternalEndPoint.Port = (int)port;
115 120
116 Scene scene = CreateScene(regionInfo, m_storageManager, circuitManager); 121 Scene scene = CreateScene(regionInfo, m_storageManager, circuitManager);
@@ -148,8 +153,8 @@ namespace OpenSim.Region.ClientStack
148 scene.RegionInfo.MasterAvatarAssignedUUID = LLUUID.Zero; 153 scene.RegionInfo.MasterAvatarAssignedUUID = LLUUID.Zero;
149 } 154 }
150 155
151 scene.LoadPrimsFromStorage(m_permissions); 156 scene.LoadPrimsFromStorage(m_permissions, regionInfo.originRegionID);
152 scene.loadAllLandObjectsFromStorage(); 157 scene.loadAllLandObjectsFromStorage(regionInfo.originRegionID);
153 scene.performParcelPrimCountUpdate(); 158 scene.performParcelPrimCountUpdate();
154 scene.StartTimer(); 159 scene.StartTimer();
155 return scene; 160 return scene;
diff --git a/OpenSim/Region/ClientStack/UDPServer.cs b/OpenSim/Region/ClientStack/UDPServer.cs
index 9c572cf..5501d3f 100644
--- a/OpenSim/Region/ClientStack/UDPServer.cs
+++ b/OpenSim/Region/ClientStack/UDPServer.cs
@@ -43,12 +43,15 @@ namespace OpenSim.Region.ClientStack
43 43
44 protected Dictionary<EndPoint, uint> clientCircuits = new Dictionary<EndPoint, uint>(); 44 protected Dictionary<EndPoint, uint> clientCircuits = new Dictionary<EndPoint, uint>();
45 public Dictionary<uint, EndPoint> clientCircuits_reverse = new Dictionary<uint, EndPoint>(); 45 public Dictionary<uint, EndPoint> clientCircuits_reverse = new Dictionary<uint, EndPoint>();
46 protected Dictionary<uint, EndPoint> proxyCircuits = new Dictionary<uint, EndPoint>();
46 public Socket Server; 47 public Socket Server;
47 protected IPEndPoint ServerIncoming; 48 protected IPEndPoint ServerIncoming;
48 protected byte[] RecvBuffer = new byte[4096]; 49 protected byte[] RecvBuffer = new byte[4096];
49 protected byte[] ZeroBuffer = new byte[8192]; 50 protected byte[] ZeroBuffer = new byte[8192];
50 protected IPEndPoint ipeSender; 51 protected IPEndPoint ipeSender;
51 protected EndPoint epSender; 52 protected EndPoint epSender;
53 protected EndPoint epProxy;
54 protected int proxyPortOffset;
52 protected AsyncCallback ReceivedData; 55 protected AsyncCallback ReceivedData;
53 protected PacketServer m_packetServer; 56 protected PacketServer m_packetServer;
54 protected ulong m_regionHandle; 57 protected ulong m_regionHandle;
@@ -85,10 +88,11 @@ namespace OpenSim.Region.ClientStack
85 { 88 {
86 } 89 }
87 90
88 public UDPServer(IPAddress _listenIP, ref uint port, bool allow_alternate_port, AssetCache assetCache, AgentCircuitManager authenticateClass) 91 public UDPServer(IPAddress _listenIP, ref uint port, int proxyPortOffset, bool allow_alternate_port, AssetCache assetCache, AgentCircuitManager authenticateClass)
89 { 92 {
93 this.proxyPortOffset = proxyPortOffset;
94 listenPort = (uint) (port + proxyPortOffset);
90 listenIP = _listenIP; 95 listenIP = _listenIP;
91 listenPort = port;
92 Allow_Alternate_Port = allow_alternate_port; 96 Allow_Alternate_Port = allow_alternate_port;
93 m_assetCache = assetCache; 97 m_assetCache = assetCache;
94 m_authenticateSessionsClass = authenticateClass; 98 m_authenticateSessionsClass = authenticateClass;
@@ -97,7 +101,7 @@ namespace OpenSim.Region.ClientStack
97 // Return new port 101 // Return new port
98 // This because in Grid mode it is not really important what port the region listens to as long as it is correctly registered. 102 // This because in Grid mode it is not really important what port the region listens to as long as it is correctly registered.
99 // So the option allow_alternate_ports="true" was added to default.xml 103 // So the option allow_alternate_ports="true" was added to default.xml
100 port = listenPort; 104 port = (uint)(listenPort - proxyPortOffset);
101 } 105 }
102 106
103 protected virtual void CreatePacketServer() 107 protected virtual void CreatePacketServer()
@@ -211,6 +215,13 @@ namespace OpenSim.Region.ClientStack
211 //return; 215 //return;
212 } 216 }
213 217
218 //System.Console.WriteLine("UDPServer : recieved message from {0}", epSender.ToString());
219 epProxy = epSender;
220 if (proxyPortOffset != 0)
221 {
222 epSender = PacketPool.DecodeProxyMessage(RecvBuffer, ref numBytes);
223 }
224
214 int packetEnd = numBytes - 1; 225 int packetEnd = numBytes - 1;
215 226
216 try 227 try
@@ -318,6 +329,9 @@ namespace OpenSim.Region.ClientStack
318 329
319 protected virtual void AddNewClient(Packet packet) 330 protected virtual void AddNewClient(Packet packet)
320 { 331 {
332 //Slave regions don't accept new clients
333 if(m_localScene.Region_Status != RegionStatus.SlaveScene)
334 {
321 UseCircuitCodePacket useCircuit = (UseCircuitCodePacket) packet; 335 UseCircuitCodePacket useCircuit = (UseCircuitCodePacket) packet;
322 lock (clientCircuits) 336 lock (clientCircuits)
323 { 337 {
@@ -334,7 +348,17 @@ namespace OpenSim.Region.ClientStack
334 m_log.Error("[UDPSERVER]: clientCurcuits_reverse already contains entry for user " + useCircuit.CircuitCode.Code.ToString() + ". NOT adding."); 348 m_log.Error("[UDPSERVER]: clientCurcuits_reverse already contains entry for user " + useCircuit.CircuitCode.Code.ToString() + ". NOT adding.");
335 } 349 }
336 350
337 PacketServer.AddNewClient(epSender, useCircuit, m_assetCache, m_authenticateSessionsClass); 351 lock (proxyCircuits)
352 {
353 if (!proxyCircuits.ContainsKey(useCircuit.CircuitCode.Code))
354 proxyCircuits.Add(useCircuit.CircuitCode.Code, epProxy);
355 else
356 m_log.Error("[UDPSERVER]: proxyCircuits already contains entry for user " + useCircuit.CircuitCode.Code.ToString() + ". NOT adding.");
357 }
358
359 PacketServer.AddNewClient(epSender, useCircuit, m_assetCache, m_authenticateSessionsClass, epProxy);
360 }
361 PacketPool.Instance.ReturnPacket(packet);
338 } 362 }
339 363
340 public void ServerListener() 364 public void ServerListener()
@@ -387,10 +411,20 @@ namespace OpenSim.Region.ClientStack
387 lock (clientCircuits_reverse) 411 lock (clientCircuits_reverse)
388 { 412 {
389 if (clientCircuits_reverse.TryGetValue(circuitcode, out sendto)) 413 if (clientCircuits_reverse.TryGetValue(circuitcode, out sendto))
390 { 414 {
391 //we found the endpoint so send the packet to it 415 //we found the endpoint so send the packet to it
392 Server.SendTo(buffer, size, flags, sendto); 416 if (proxyPortOffset != 0)
393 } 417 {
418 //MainLog.Instance.Verbose("UDPSERVER", "SendPacketTo proxy " + proxyCircuits[circuitcode].ToString() + ": client " + sendto.ToString());
419 PacketPool.EncodeProxyMessage(buffer, ref size, sendto);
420 Server.SendTo(buffer, size, flags, proxyCircuits[circuitcode]);
421 }
422 else
423 {
424 //MainLog.Instance.Verbose("UDPSERVER", "SendPacketTo : client " + sendto.ToString());
425 Server.SendTo(buffer, size, flags, sendto);
426 }
427 }
394 } 428 }
395 } 429 }
396 430
@@ -404,8 +438,50 @@ namespace OpenSim.Region.ClientStack
404 clientCircuits.Remove(sendto); 438 clientCircuits.Remove(sendto);
405 439
406 clientCircuits_reverse.Remove(circuitcode); 440 clientCircuits_reverse.Remove(circuitcode);
441 proxyCircuits.Remove(circuitcode);
407 } 442 }
408 } 443 }
409 } 444 }
445
446 public void RestoreClient(AgentCircuitData circuit, EndPoint userEP, EndPoint proxyEP)
447 {
448 //MainLog.Instance.Verbose("UDPSERVER", "RestoreClient");
449
450 UseCircuitCodePacket useCircuit = new UseCircuitCodePacket();
451 useCircuit.CircuitCode.Code = circuit.circuitcode;
452 useCircuit.CircuitCode.ID = circuit.AgentID;
453 useCircuit.CircuitCode.SessionID = circuit.SessionID;
454
455 lock (clientCircuits)
456 {
457 if (!clientCircuits.ContainsKey(userEP))
458 clientCircuits.Add(userEP, useCircuit.CircuitCode.Code);
459 else
460 m_log.Error("[UDPSERVER]: clientCircuits already contans entry for user " + useCircuit.CircuitCode.Code.ToString() + ". NOT adding.");
461 }
462 lock (clientCircuits_reverse)
463 {
464 if (!clientCircuits_reverse.ContainsKey(useCircuit.CircuitCode.Code))
465 clientCircuits_reverse.Add(useCircuit.CircuitCode.Code, userEP);
466 else
467 m_log.Error("[UDPSERVER]: clientCurcuits_reverse already contains entry for user " + useCircuit.CircuitCode.Code.ToString() + ". NOT adding.");
468 }
469
470 lock (proxyCircuits)
471 {
472 if (!proxyCircuits.ContainsKey(useCircuit.CircuitCode.Code))
473 {
474 proxyCircuits.Add(useCircuit.CircuitCode.Code, proxyEP);
475 }
476 else
477 {
478 // re-set proxy endpoint
479 proxyCircuits.Remove(useCircuit.CircuitCode.Code);
480 proxyCircuits.Add(useCircuit.CircuitCode.Code, proxyEP);
481 }
482 }
483
484 PacketServer.AddNewClient(userEP, useCircuit, m_assetCache, m_authenticateSessionsClass, proxyEP);
485 }
410 } 486 }
411} 487}