diff options
author | Johan Berntsson | 2008-03-04 05:31:54 +0000 |
---|---|---|
committer | Johan Berntsson | 2008-03-04 05:31:54 +0000 |
commit | 279e0061c515ee0a03036bef68eea9738273d785 (patch) | |
tree | 4502228eb7b87a760e0b0e67aded9d1d870d0bed /OpenSim/Region/ClientStack/ClientView.cs | |
parent | Added copyright heaaders. Minor cleanup. (diff) | |
download | opensim-SC_OLD-279e0061c515ee0a03036bef68eea9738273d785.zip opensim-SC_OLD-279e0061c515ee0a03036bef68eea9738273d785.tar.gz opensim-SC_OLD-279e0061c515ee0a03036bef68eea9738273d785.tar.bz2 opensim-SC_OLD-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 'OpenSim/Region/ClientStack/ClientView.cs')
-rw-r--r-- | OpenSim/Region/ClientStack/ClientView.cs | 145 |
1 files changed, 141 insertions, 4 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 | } |