aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim.RegionServer/SimClient.cs
diff options
context:
space:
mode:
authorMW2007-05-16 16:01:01 +0000
committerMW2007-05-16 16:01:01 +0000
commitbd6e69b97c0d62eafd65ce6079675ad43a26309e (patch)
treec85d01460b3b46431d8783b62e11686633da90e1 /OpenSim.RegionServer/SimClient.cs
parentMore refactoring. (diff)
downloadopensim-SC_OLD-bd6e69b97c0d62eafd65ce6079675ad43a26309e.zip
opensim-SC_OLD-bd6e69b97c0d62eafd65ce6079675ad43a26309e.tar.gz
opensim-SC_OLD-bd6e69b97c0d62eafd65ce6079675ad43a26309e.tar.bz2
opensim-SC_OLD-bd6e69b97c0d62eafd65ce6079675ad43a26309e.tar.xz
Yet more cleanup/refactoring
Diffstat (limited to '')
-rw-r--r--OpenSim.RegionServer/SimClient.cs52
1 files changed, 32 insertions, 20 deletions
diff --git a/OpenSim.RegionServer/SimClient.cs b/OpenSim.RegionServer/SimClient.cs
index 81da10e..5bd098b 100644
--- a/OpenSim.RegionServer/SimClient.cs
+++ b/OpenSim.RegionServer/SimClient.cs
@@ -109,8 +109,8 @@ namespace OpenSim
109 m_sandboxMode = sandboxMode; 109 m_sandboxMode = sandboxMode;
110 m_child = child; 110 m_child = child;
111 m_regionData = regionDat; 111 m_regionData = regionDat;
112 112
113 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"OpenSimClient.cs - Started up new client thread to handle incoming request"); 113 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "OpenSimClient.cs - Started up new client thread to handle incoming request");
114 cirpack = initialcirpack; 114 cirpack = initialcirpack;
115 userEP = remoteEP; 115 userEP = remoteEP;
116 if (m_gridServer.GetName() == "Remote") 116 if (m_gridServer.GetName() == "Remote")
@@ -135,16 +135,10 @@ namespace OpenSim
135 ClientThread.Start(); 135 ClientThread.Start();
136 } 136 }
137 137
138 protected virtual void RegisterLocalPacketHandlers() 138 # region Client Methods
139 {
140 this.AddLocalPacketHandler(PacketType.LogoutRequest, this.Logout);
141 this.AddLocalPacketHandler(PacketType.AgentCachedTexture, this.AgentTextureCached);
142 this.AddLocalPacketHandler(PacketType.MultipleObjectUpdate, this.MultipleObjUpdate);
143 }
144
145 public void UpgradeClient() 139 public void UpgradeClient()
146 { 140 {
147 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"SimClient.cs:UpgradeClient() - upgrading child to full agent"); 141 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "SimClient.cs:UpgradeClient() - upgrading child to full agent");
148 this.m_child = false; 142 this.m_child = false;
149 this.m_world.RemoveViewerAgent(this); 143 this.m_world.RemoveViewerAgent(this);
150 if (!this.m_sandboxMode) 144 if (!this.m_sandboxMode)
@@ -157,7 +151,7 @@ namespace OpenSim
157 151
158 public void DowngradeClient() 152 public void DowngradeClient()
159 { 153 {
160 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"SimClient.cs:UpgradeClient() - changing full agent to child"); 154 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "SimClient.cs:UpgradeClient() - changing full agent to child");
161 this.m_child = true; 155 this.m_child = true;
162 this.m_world.RemoveViewerAgent(this); 156 this.m_world.RemoveViewerAgent(this);
163 this.m_world.AddViewerAgent(this); 157 this.m_world.AddViewerAgent(this);
@@ -188,7 +182,9 @@ namespace OpenSim
188 m_networkServer.RemoveClientCircuit(this.CircuitCode); 182 m_networkServer.RemoveClientCircuit(this.CircuitCode);
189 this.ClientThread.Abort(); 183 this.ClientThread.Abort();
190 } 184 }
185 #endregion
191 186
187 # region Packet Handling
192 public static bool AddPacketHandler(PacketType packetType, PacketMethod handler) 188 public static bool AddPacketHandler(PacketType packetType, PacketMethod handler)
193 { 189 {
194 bool result = false; 190 bool result = false;
@@ -242,6 +238,10 @@ namespace OpenSim
242 return result; 238 return result;
243 } 239 }
244 240
241 # endregion
242
243 # region Low Level Packet Methods
244
245 private void ack_pack(Packet Pack) 245 private void ack_pack(Packet Pack)
246 { 246 {
247 if (Pack.Header.Reliable) 247 if (Pack.Header.Reliable)
@@ -276,7 +276,7 @@ namespace OpenSim
276 { 276 {
277 if ((now - packet.TickCount > RESEND_TIMEOUT) && (!packet.Header.Resent)) 277 if ((now - packet.TickCount > RESEND_TIMEOUT) && (!packet.Header.Resent))
278 { 278 {
279 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.VERBOSE,"Resending " + packet.Type.ToString() + " packet, " + 279 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.VERBOSE, "Resending " + packet.Type.ToString() + " packet, " +
280 (now - packet.TickCount) + "ms have passed"); 280 (now - packet.TickCount) + "ms have passed");
281 281
282 packet.Header.Resent = true; 282 packet.Header.Resent = true;
@@ -295,7 +295,7 @@ namespace OpenSim
295 if (PendingAcks.Count > 250) 295 if (PendingAcks.Count > 250)
296 { 296 {
297 // FIXME: Handle the odd case where we have too many pending ACKs queued up 297 // FIXME: Handle the odd case where we have too many pending ACKs queued up
298 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.VERBOSE,"Too many ACKs queued up!"); 298 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.VERBOSE, "Too many ACKs queued up!");
299 return; 299 return;
300 } 300 }
301 301
@@ -327,6 +327,10 @@ namespace OpenSim
327 ResendUnacked(); 327 ResendUnacked();
328 } 328 }
329 329
330 # endregion
331
332 #region Packet Queue Processing
333
330 protected virtual void ProcessOutPacket(Packet Pack) 334 protected virtual void ProcessOutPacket(Packet Pack)
331 { 335 {
332 // Keep track of when this packet was sent out 336 // Keep track of when this packet was sent out
@@ -417,7 +421,7 @@ namespace OpenSim
417 } 421 }
418 catch (Exception) 422 catch (Exception)
419 { 423 {
420 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM,"OpenSimClient.cs:ProcessOutPacket() - WARNING: Socket exception occurred on connection " + userEP.ToString() + " - killing thread"); 424 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "OpenSimClient.cs:ProcessOutPacket() - WARNING: Socket exception occurred on connection " + userEP.ToString() + " - killing thread");
421 ClientThread.Abort(); 425 ClientThread.Abort();
422 } 426 }
423 427
@@ -478,7 +482,7 @@ namespace OpenSim
478 482
479 protected virtual void ClientLoop() 483 protected virtual void ClientLoop()
480 { 484 {
481 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"OpenSimClient.cs:ClientLoop() - Entered loop"); 485 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "OpenSimClient.cs:ClientLoop() - Entered loop");
482 while (true) 486 while (true)
483 { 487 {
484 QueItem nextPacket = PacketQueue.Dequeue(); 488 QueItem nextPacket = PacketQueue.Dequeue();
@@ -495,9 +499,13 @@ namespace OpenSim
495 } 499 }
496 } 500 }
497 501
502 #endregion
503
504 # region Setup
505
498 protected virtual void InitNewClient() 506 protected virtual void InitNewClient()
499 { 507 {
500 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"OpenSimClient.cs:InitNewClient() - Adding viewer agent to world"); 508 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "OpenSimClient.cs:InitNewClient() - Adding viewer agent to world");
501 509
502 m_world.AddViewerAgent(this); 510 m_world.AddViewerAgent(this);
503 world.Entity tempent = m_world.Entities[this.AgentID]; 511 world.Entity tempent = m_world.Entities[this.AgentID];
@@ -507,17 +515,17 @@ namespace OpenSim
507 515
508 protected virtual void AuthUser() 516 protected virtual void AuthUser()
509 { 517 {
510 // AuthenticateResponse sessionInfo = m_gridServer.AuthenticateSession(cirpack.CircuitCode.SessionID, cirpack.CircuitCode.ID, cirpack.CircuitCode.Code); 518 // AuthenticateResponse sessionInfo = m_gridServer.AuthenticateSession(cirpack.CircuitCode.SessionID, cirpack.CircuitCode.ID, cirpack.CircuitCode.Code);
511 AuthenticateResponse sessionInfo = this.m_networkServer.AuthenticateSession(cirpack.CircuitCode.SessionID, cirpack.CircuitCode.ID, cirpack.CircuitCode.Code); 519 AuthenticateResponse sessionInfo = this.m_networkServer.AuthenticateSession(cirpack.CircuitCode.SessionID, cirpack.CircuitCode.ID, cirpack.CircuitCode.Code);
512 if (!sessionInfo.Authorised) 520 if (!sessionInfo.Authorised)
513 { 521 {
514 //session/circuit not authorised 522 //session/circuit not authorised
515 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.NORMAL,"OpenSimClient.cs:AuthUser() - New user request denied to " + userEP.ToString()); 523 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.NORMAL, "OpenSimClient.cs:AuthUser() - New user request denied to " + userEP.ToString());
516 ClientThread.Abort(); 524 ClientThread.Abort();
517 } 525 }
518 else 526 else
519 { 527 {
520 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.NORMAL,"OpenSimClient.cs:AuthUser() - Got authenticated connection from " + userEP.ToString()); 528 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.NORMAL, "OpenSimClient.cs:AuthUser() - Got authenticated connection from " + userEP.ToString());
521 //session is authorised 529 //session is authorised
522 this.AgentID = cirpack.CircuitCode.ID; 530 this.AgentID = cirpack.CircuitCode.ID;
523 this.SessionID = cirpack.CircuitCode.SessionID; 531 this.SessionID = cirpack.CircuitCode.SessionID;
@@ -539,9 +547,10 @@ namespace OpenSim
539 ClientLoop(); 547 ClientLoop();
540 } 548 }
541 } 549 }
550 # endregion
542 551
543 #region Inventory Creation 552 #region Inventory Creation
544 private void SetupInventory(AuthenticateResponse sessionInfo) 553 private void SetupInventory(AuthenticateResponse sessionInfo)
545 { 554 {
546 AgentInventory inventory = null; 555 AgentInventory inventory = null;
547 if (sessionInfo.LoginInfo.InventoryFolder != null) 556 if (sessionInfo.LoginInfo.InventoryFolder != null)
@@ -630,6 +639,8 @@ namespace OpenSim
630 } 639 }
631 #endregion 640 #endregion
632 641
642 #region Nested Classes
643
633 public class QueItem 644 public class QueItem
634 { 645 {
635 public QueItem() 646 public QueItem()
@@ -639,5 +650,6 @@ namespace OpenSim
639 public Packet Packet; 650 public Packet Packet;
640 public bool Incoming; 651 public bool Incoming;
641 } 652 }
653 #endregion
642 } 654 }
643} 655}