diff options
author | Adam Frisby | 2007-07-11 02:51:51 +0000 |
---|---|---|
committer | Adam Frisby | 2007-07-11 02:51:51 +0000 |
commit | 561b87b303e8e141ef516b8725ebd3c0be8b1122 (patch) | |
tree | 8405b6cef57b66a58f31a24c859846085d0b81f7 /OpenSim/Region/ClientStack/ClientView.cs | |
parent | preliminary inter region communications (between regions in different instanc... (diff) | |
download | opensim-SC_OLD-561b87b303e8e141ef516b8725ebd3c0be8b1122.zip opensim-SC_OLD-561b87b303e8e141ef516b8725ebd3c0be8b1122.tar.gz opensim-SC_OLD-561b87b303e8e141ef516b8725ebd3c0be8b1122.tar.bz2 opensim-SC_OLD-561b87b303e8e141ef516b8725ebd3c0be8b1122.tar.xz |
* Applying dalien's patches from bug#177 and #179
Diffstat (limited to 'OpenSim/Region/ClientStack/ClientView.cs')
-rw-r--r-- | OpenSim/Region/ClientStack/ClientView.cs | 40 |
1 files changed, 31 insertions, 9 deletions
diff --git a/OpenSim/Region/ClientStack/ClientView.cs b/OpenSim/Region/ClientStack/ClientView.cs index 52749a1..0fe3884 100644 --- a/OpenSim/Region/ClientStack/ClientView.cs +++ b/OpenSim/Region/ClientStack/ClientView.cs | |||
@@ -25,6 +25,7 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | using System; | ||
28 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
29 | using System.Net; | 30 | using System.Net; |
30 | using System.Text; | 31 | using System.Text; |
@@ -77,6 +78,11 @@ namespace OpenSim.Region.ClientStack | |||
77 | private int cachedtextureserial = 0; | 78 | private int cachedtextureserial = 0; |
78 | protected AuthenticateSessionsBase m_authenticateSessionsHandler; | 79 | protected AuthenticateSessionsBase m_authenticateSessionsHandler; |
79 | private Encoding enc = Encoding.ASCII; | 80 | private Encoding enc = Encoding.ASCII; |
81 | // Dead client detection vars | ||
82 | private Timer clientPingTimer; | ||
83 | private int packetsReceived = 0; | ||
84 | private int probesWithNoIngressPackets = 0; | ||
85 | private int lastPacketsReceived = 0; | ||
80 | 86 | ||
81 | public ClientView(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, Dictionary<uint, ClientView> clientThreads, IWorld world, AssetCache assetCache, PacketServer packServer, InventoryCache inventoryCache, AuthenticateSessionsBase authenSessions ) | 87 | public ClientView(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, Dictionary<uint, ClientView> clientThreads, IWorld world, AssetCache assetCache, PacketServer packServer, InventoryCache inventoryCache, AuthenticateSessionsBase authenSessions ) |
82 | { | 88 | { |
@@ -112,15 +118,7 @@ namespace OpenSim.Region.ClientStack | |||
112 | 118 | ||
113 | public void KillClient() | 119 | public void KillClient() |
114 | { | 120 | { |
115 | KillObjectPacket kill = new KillObjectPacket(); | 121 | clientPingTimer.Stop(); |
116 | kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1]; | ||
117 | kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock(); | ||
118 | //kill.ObjectData[0].ID = this.ClientAvatar.localid; | ||
119 | foreach (ClientView client in m_clientThreads.Values) | ||
120 | { | ||
121 | client.OutPacket(kill); | ||
122 | } | ||
123 | |||
124 | this.m_inventoryCache.ClientLeaving(this.AgentID, null); | 122 | this.m_inventoryCache.ClientLeaving(this.AgentID, null); |
125 | m_world.RemoveClient(this.AgentId); | 123 | m_world.RemoveClient(this.AgentId); |
126 | 124 | ||
@@ -193,6 +191,9 @@ namespace OpenSim.Region.ClientStack | |||
193 | if (nextPacket.Incoming) | 191 | if (nextPacket.Incoming) |
194 | { | 192 | { |
195 | //is a incoming packet | 193 | //is a incoming packet |
194 | if (nextPacket.Packet.Type != PacketType.AgentUpdate) { | ||
195 | packetsReceived++; | ||
196 | } | ||
196 | ProcessInPacket(nextPacket.Packet); | 197 | ProcessInPacket(nextPacket.Packet); |
197 | } | 198 | } |
198 | else | 199 | else |
@@ -204,10 +205,31 @@ namespace OpenSim.Region.ClientStack | |||
204 | } | 205 | } |
205 | # endregion | 206 | # endregion |
206 | 207 | ||
208 | protected void CheckClientConnectivity(object sender, ElapsedEventArgs e) | ||
209 | { | ||
210 | if (packetsReceived == lastPacketsReceived) { | ||
211 | probesWithNoIngressPackets++; | ||
212 | if (probesWithNoIngressPackets > 30) { | ||
213 | this.KillClient(); | ||
214 | } else { | ||
215 | // this will normally trigger at least one packet (ping response) | ||
216 | SendStartPingCheck(0); | ||
217 | } | ||
218 | } else { | ||
219 | // Something received in the meantime - we can reset the counters | ||
220 | probesWithNoIngressPackets = 0; | ||
221 | lastPacketsReceived = packetsReceived; | ||
222 | } | ||
223 | } | ||
224 | |||
207 | # region Setup | 225 | # region Setup |
208 | 226 | ||
209 | protected virtual void InitNewClient() | 227 | protected virtual void InitNewClient() |
210 | { | 228 | { |
229 | clientPingTimer = new Timer(1000); | ||
230 | clientPingTimer.Elapsed += new ElapsedEventHandler(CheckClientConnectivity); | ||
231 | clientPingTimer.Enabled = true; | ||
232 | |||
211 | MainLog.Instance.Verbose( "OpenSimClient.cs:InitNewClient() - Adding viewer agent to world"); | 233 | MainLog.Instance.Verbose( "OpenSimClient.cs:InitNewClient() - Adding viewer agent to world"); |
212 | this.m_world.AddNewClient(this, false); | 234 | this.m_world.AddNewClient(this, false); |
213 | } | 235 | } |