aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/ClientStack/ClientView.API.cs4
-rw-r--r--OpenSim/Region/ClientStack/ClientView.PacketHandlers.cs17
-rw-r--r--OpenSim/Region/ClientStack/ClientView.PacketQueue.cs12
-rw-r--r--OpenSim/Region/ClientStack/ClientView.cs14
-rw-r--r--OpenSim/Region/ClientStack/PacketServer.cs41
-rw-r--r--OpenSim/Region/ClientStack/UDPServer.cs16
-rw-r--r--OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs17
7 files changed, 78 insertions, 43 deletions
diff --git a/OpenSim/Region/ClientStack/ClientView.API.cs b/OpenSim/Region/ClientStack/ClientView.API.cs
index a15a964..253807c 100644
--- a/OpenSim/Region/ClientStack/ClientView.API.cs
+++ b/OpenSim/Region/ClientStack/ClientView.API.cs
@@ -42,6 +42,8 @@ namespace OpenSim.Region.ClientStack
42{ 42{
43 partial class ClientView 43 partial class ClientView
44 { 44 {
45 public event Action<IClientAPI> OnLogout;
46 public event Action<IClientAPI> OnConnectionClosed;
45 public event ViewerEffectEventHandler OnViewerEffect; 47 public event ViewerEffectEventHandler OnViewerEffect;
46 public event ImprovedInstantMessage OnInstantMessage; 48 public event ImprovedInstantMessage OnInstantMessage;
47 public event ChatFromViewer OnChatFromViewer; 49 public event ChatFromViewer OnChatFromViewer;
@@ -373,7 +375,7 @@ namespace OpenSim.Region.ClientStack
373 agentData.AgentID = this.AgentId; 375 agentData.AgentID = this.AgentId;
374 agentData.SessionID = this.m_sessionId; 376 agentData.SessionID = this.m_sessionId;
375 agentData.SecureSessionID = this.SecureSessionID; 377 agentData.SecureSessionID = this.SecureSessionID;
376 agentData.circuitcode = this.CircuitCode; 378 agentData.circuitcode = this.m_circuitCode;
377 agentData.child = false; 379 agentData.child = false;
378 agentData.firstname = this.firstName; 380 agentData.firstname = this.firstName;
379 agentData.lastname = this.lastName; 381 agentData.lastname = this.lastName;
diff --git a/OpenSim/Region/ClientStack/ClientView.PacketHandlers.cs b/OpenSim/Region/ClientStack/ClientView.PacketHandlers.cs
index 65ad431..643b158 100644
--- a/OpenSim/Region/ClientStack/ClientView.PacketHandlers.cs
+++ b/OpenSim/Region/ClientStack/ClientView.PacketHandlers.cs
@@ -56,19 +56,12 @@ namespace OpenSim.Region.ClientStack
56 56
57 protected virtual bool Logout(IClientAPI client, Packet packet) 57 protected virtual bool Logout(IClientAPI client, Packet packet)
58 { 58 {
59 // TODO: Refactor out this into an OnLogout so the ClientManager can close all clients.
60
61 MainLog.Instance.Verbose("OpenSimClient.cs:ProcessInPacket() - Got a logout request"); 59 MainLog.Instance.Verbose("OpenSimClient.cs:ProcessInPacket() - Got a logout request");
62 //send reply to let the client logout 60
63 LogoutReplyPacket logReply = new LogoutReplyPacket(); 61 if( OnLogout != null )
64 logReply.AgentData.AgentID = this.AgentId; 62 {
65 logReply.AgentData.SessionID = this.m_sessionId; 63 OnLogout(client);
66 logReply.InventoryData = new LogoutReplyPacket.InventoryDataBlock[1]; 64 }
67 logReply.InventoryData[0] = new LogoutReplyPacket.InventoryDataBlock();
68 logReply.InventoryData[0].ItemID = LLUUID.Zero;
69 OutPacket(logReply);
70 //
71 this.Close();
72 65
73 return true; 66 return true;
74 } 67 }
diff --git a/OpenSim/Region/ClientStack/ClientView.PacketQueue.cs b/OpenSim/Region/ClientStack/ClientView.PacketQueue.cs
index 05c2869..bfcb19f 100644
--- a/OpenSim/Region/ClientStack/ClientView.PacketQueue.cs
+++ b/OpenSim/Region/ClientStack/ClientView.PacketQueue.cs
@@ -51,11 +51,17 @@ namespace OpenSim.Region.ClientStack
51 protected const int RESEND_TIMEOUT = 4000; 51 protected const int RESEND_TIMEOUT = 4000;
52 protected const int MAX_SEQUENCE = 0xFFFFFF; 52 protected const int MAX_SEQUENCE = 0xFFFFFF;
53 53
54 public uint CircuitCode; 54 private uint m_circuitCode;
55 public EndPoint userEP; 55 public EndPoint userEP;
56 56
57 protected PacketServer m_networkServer; 57 protected PacketServer m_networkServer;
58 58
59 public uint CircuitCode
60 {
61 get { return m_circuitCode; }
62 set { m_circuitCode = value; }
63 }
64
59 protected virtual void ProcessOutPacket(Packet Pack) 65 protected virtual void ProcessOutPacket(Packet Pack)
60 { 66 {
61 // Keep track of when this packet was sent out 67 // Keep track of when this packet was sent out
@@ -142,11 +148,11 @@ namespace OpenSim.Region.ClientStack
142 if (Pack.Header.Zerocoded) 148 if (Pack.Header.Zerocoded)
143 { 149 {
144 int packetsize = Helpers.ZeroEncode(sendbuffer, sendbuffer.Length, ZeroOutBuffer); 150 int packetsize = Helpers.ZeroEncode(sendbuffer, sendbuffer.Length, ZeroOutBuffer);
145 m_networkServer.SendPacketTo(ZeroOutBuffer, packetsize, SocketFlags.None, CircuitCode);//userEP); 151 m_networkServer.SendPacketTo(ZeroOutBuffer, packetsize, SocketFlags.None, m_circuitCode);//userEP);
146 } 152 }
147 else 153 else
148 { 154 {
149 m_networkServer.SendPacketTo(sendbuffer, sendbuffer.Length, SocketFlags.None, CircuitCode); //userEP); 155 m_networkServer.SendPacketTo(sendbuffer, sendbuffer.Length, SocketFlags.None, m_circuitCode); //userEP);
150 } 156 }
151 } 157 }
152 catch (Exception) 158 catch (Exception)
diff --git a/OpenSim/Region/ClientStack/ClientView.cs b/OpenSim/Region/ClientStack/ClientView.cs
index f8ac1d8..2341b7b 100644
--- a/OpenSim/Region/ClientStack/ClientView.cs
+++ b/OpenSim/Region/ClientStack/ClientView.cs
@@ -133,8 +133,6 @@ namespace OpenSim.Region.ClientStack
133 133
134 m_scene.RemoveClient(this.AgentId); 134 m_scene.RemoveClient(this.AgentId);
135 135
136 m_clientManager.Remove(this.CircuitCode); // TODO: Move out and delete ref to clientmanager.
137 m_networkServer.RemoveClientCircuit(this.CircuitCode);
138 this.ClientThread.Abort(); 136 this.ClientThread.Abort();
139 } 137 }
140 138
@@ -215,7 +213,7 @@ namespace OpenSim.Region.ClientStack
215 } else { 213 } else {
216 info = packet.Type.ToString(); 214 info = packet.Type.ToString();
217 } 215 }
218 Console.WriteLine(CircuitCode + ":" + direction + ": " + info); 216 Console.WriteLine(m_circuitCode + ":" + direction + ": " + info);
219 } 217 }
220 } 218 }
221 219
@@ -252,8 +250,10 @@ namespace OpenSim.Region.ClientStack
252 probesWithNoIngressPackets++; 250 probesWithNoIngressPackets++;
253 if (probesWithNoIngressPackets > 30) 251 if (probesWithNoIngressPackets > 30)
254 { 252 {
255 // Refactor out this into an OnConnectionClosed so the ClientManager can clean up 253 if( OnConnectionClosed != null )
256 this.Close(); 254 {
255 OnConnectionClosed(this);
256 }
257 } 257 }
258 else 258 else
259 { 259 {
@@ -283,7 +283,7 @@ namespace OpenSim.Region.ClientStack
283 283
284 protected virtual void AuthUser() 284 protected virtual void AuthUser()
285 { 285 {
286 // AuthenticateResponse sessionInfo = m_gridServer.AuthenticateSession(cirpack.CircuitCode.m_sessionId, cirpack.CircuitCode.ID, cirpack.CircuitCode.Code); 286 // AuthenticateResponse sessionInfo = m_gridServer.AuthenticateSession(cirpack.m_circuitCode.m_sessionId, cirpack.m_circuitCode.ID, cirpack.m_circuitCode.Code);
287 AuthenticateResponse sessionInfo = this.m_authenticateSessionsHandler.AuthenticateSession(cirpack.CircuitCode.SessionID, cirpack.CircuitCode.ID, cirpack.CircuitCode.Code); 287 AuthenticateResponse sessionInfo = this.m_authenticateSessionsHandler.AuthenticateSession(cirpack.CircuitCode.SessionID, cirpack.CircuitCode.ID, cirpack.CircuitCode.Code);
288 if (!sessionInfo.Authorised) 288 if (!sessionInfo.Authorised)
289 { 289 {
@@ -297,7 +297,7 @@ namespace OpenSim.Region.ClientStack
297 //session is authorised 297 //session is authorised
298 m_agentId = cirpack.CircuitCode.ID; 298 m_agentId = cirpack.CircuitCode.ID;
299 this.m_sessionId = cirpack.CircuitCode.SessionID; 299 this.m_sessionId = cirpack.CircuitCode.SessionID;
300 this.CircuitCode = cirpack.CircuitCode.Code; 300 this.m_circuitCode = cirpack.CircuitCode.Code;
301 this.firstName = sessionInfo.LoginInfo.First; 301 this.firstName = sessionInfo.LoginInfo.First;
302 this.lastName = sessionInfo.LoginInfo.Last; 302 this.lastName = sessionInfo.LoginInfo.Last;
303 303
diff --git a/OpenSim/Region/ClientStack/PacketServer.cs b/OpenSim/Region/ClientStack/PacketServer.cs
index bceeeb3..28f25bd 100644
--- a/OpenSim/Region/ClientStack/PacketServer.cs
+++ b/OpenSim/Region/ClientStack/PacketServer.cs
@@ -33,14 +33,15 @@ using OpenSim.Framework;
33using OpenSim.Framework.Types; 33using OpenSim.Framework.Types;
34using OpenSim.Framework.Interfaces; 34using OpenSim.Framework.Interfaces;
35using OpenSim.Framework.Communications.Caches; 35using OpenSim.Framework.Communications.Caches;
36using libsecondlife;
36 37
37namespace OpenSim.Region.ClientStack 38namespace OpenSim.Region.ClientStack
38{ 39{
39 public class PacketServer 40 public class PacketServer
40 { 41 {
41 private ClientStackNetworkHandler _networkHandler; 42 private ClientStackNetworkHandler m_networkHandler;
42 private IScene _localScene; 43 private IScene _localScene;
43 private ClientManager m_clientManager = new ClientManager(); 44 private readonly ClientManager m_clientManager = new ClientManager();
44 public ClientManager ClientManager 45 public ClientManager ClientManager
45 { 46 {
46 get { return m_clientManager; } 47 get { return m_clientManager; }
@@ -48,8 +49,8 @@ namespace OpenSim.Region.ClientStack
48 49
49 public PacketServer(ClientStackNetworkHandler networkHandler) 50 public PacketServer(ClientStackNetworkHandler networkHandler)
50 { 51 {
51 _networkHandler = networkHandler; 52 m_networkHandler = networkHandler;
52 _networkHandler.RegisterPacketServer(this); 53 m_networkHandler.RegisterPacketServer(this);
53 } 54 }
54 55
55 public IScene LocalScene 56 public IScene LocalScene
@@ -70,11 +71,6 @@ namespace OpenSim.Region.ClientStack
70 m_clientManager.InPacket(circuitCode, packet); 71 m_clientManager.InPacket(circuitCode, packet);
71 } 72 }
72 73
73 public virtual void ConnectionClosed(uint circuitCode)
74 {
75 m_clientManager.ConnectionClosed(circuitCode);
76 }
77
78 /// <summary> 74 /// <summary>
79 /// 75 ///
80 /// </summary> 76 /// </summary>
@@ -145,10 +141,24 @@ namespace OpenSim.Region.ClientStack
145 this.m_clientManager.Add(useCircuit.CircuitCode.Code, newuser); 141 this.m_clientManager.Add(useCircuit.CircuitCode.Code, newuser);
146 142
147 newuser.OnViewerEffect += m_clientManager.ViewerEffectHandler; 143 newuser.OnViewerEffect += m_clientManager.ViewerEffectHandler;
144 newuser.OnLogout += LogoutHandler;
145 newuser.OnConnectionClosed += CloseClient;
148 146
149 return true; 147 return true;
150 } 148 }
151 149
150 public void LogoutHandler(IClientAPI client)
151 {
152 LogoutReplyPacket logReply = new LogoutReplyPacket();
153 logReply.AgentData.AgentID = client.AgentId;
154 logReply.AgentData.SessionID = client.SessionId;
155 logReply.InventoryData = new LogoutReplyPacket.InventoryDataBlock[1];
156 logReply.InventoryData[0] = new LogoutReplyPacket.InventoryDataBlock();
157 logReply.InventoryData[0].ItemID = LLUUID.Zero;
158 client.OutPacket(logReply);
159
160 CloseClient( client );
161 }
152 162
153 163
154 /// <summary> 164 /// <summary>
@@ -160,17 +170,22 @@ namespace OpenSim.Region.ClientStack
160 /// <param name="circuitcode"></param> 170 /// <param name="circuitcode"></param>
161 public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode) 171 public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)
162 { 172 {
163 this._networkHandler.SendPacketTo(buffer, size, flags, circuitcode); 173 this.m_networkHandler.SendPacketTo(buffer, size, flags, circuitcode);
164 } 174 }
165 175
166 /// <summary> 176 /// <summary>
167 /// 177 ///
168 /// </summary> 178 /// </summary>
169 /// <param name="circuitcode"></param> 179 /// <param name="circuitcode"></param>
170 public virtual void RemoveClientCircuit(uint circuitcode) 180 public virtual void CloseCircuit(uint circuitcode)
181 {
182 m_networkHandler.RemoveClientCircuit( circuitcode );
183 m_clientManager.CloseAllAgents( circuitcode );
184 }
185
186 public virtual void CloseClient( IClientAPI client )
171 { 187 {
172 this._networkHandler.RemoveClientCircuit(circuitcode); 188 CloseCircuit( client.CircuitCode );
173 this.m_clientManager.Remove(circuitcode);
174 } 189 }
175 } 190 }
176} 191}
diff --git a/OpenSim/Region/ClientStack/UDPServer.cs b/OpenSim/Region/ClientStack/UDPServer.cs
index efc9c87..b0b529c 100644
--- a/OpenSim/Region/ClientStack/UDPServer.cs
+++ b/OpenSim/Region/ClientStack/UDPServer.cs
@@ -49,7 +49,7 @@ namespace OpenSim.Region.ClientStack
49 protected IPEndPoint ipeSender; 49 protected IPEndPoint ipeSender;
50 protected EndPoint epSender; 50 protected EndPoint epSender;
51 protected AsyncCallback ReceivedData; 51 protected AsyncCallback ReceivedData;
52 protected PacketServer _packetServer; 52 protected PacketServer m_packetServer;
53 53
54 protected int listenPort; 54 protected int listenPort;
55 protected IScene m_localScene; 55 protected IScene m_localScene;
@@ -61,11 +61,11 @@ namespace OpenSim.Region.ClientStack
61 { 61 {
62 get 62 get
63 { 63 {
64 return _packetServer; 64 return m_packetServer;
65 } 65 }
66 set 66 set
67 { 67 {
68 _packetServer = value; 68 m_packetServer = value;
69 } 69 }
70 } 70 }
71 71
@@ -74,7 +74,7 @@ namespace OpenSim.Region.ClientStack
74 set 74 set
75 { 75 {
76 this.m_localScene = value; 76 this.m_localScene = value;
77 this._packetServer.LocalScene = this.m_localScene; 77 this.m_packetServer.LocalScene = this.m_localScene;
78 } 78 }
79 } 79 }
80 80
@@ -111,7 +111,9 @@ namespace OpenSim.Region.ClientStack
111 catch (System.Net.Sockets.SocketException) 111 catch (System.Net.Sockets.SocketException)
112 { 112 {
113 Console.WriteLine("Remote host Closed connection"); 113 Console.WriteLine("Remote host Closed connection");
114 this._packetServer.ConnectionClosed(this.clientCircuits[epSender]); 114
115 this.m_packetServer.CloseCircuit(this.clientCircuits[epSender]);
116
115 ipeSender = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0); 117 ipeSender = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0);
116 epSender = (EndPoint)ipeSender; 118 epSender = (EndPoint)ipeSender;
117 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); 119 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
@@ -126,7 +128,7 @@ namespace OpenSim.Region.ClientStack
126 if (this.clientCircuits.ContainsKey(epSender)) 128 if (this.clientCircuits.ContainsKey(epSender))
127 { 129 {
128 //if so then send packet to the packetserver 130 //if so then send packet to the packetserver
129 this._packetServer.InPacket(this.clientCircuits[epSender], packet); 131 this.m_packetServer.InPacket(this.clientCircuits[epSender], packet);
130 } 132 }
131 else if (packet.Type == PacketType.UseCircuitCode) 133 else if (packet.Type == PacketType.UseCircuitCode)
132 { 134 {
@@ -170,7 +172,7 @@ namespace OpenSim.Region.ClientStack
170 172
171 public virtual void RegisterPacketServer(PacketServer server) 173 public virtual void RegisterPacketServer(PacketServer server)
172 { 174 {
173 this._packetServer = server; 175 this.m_packetServer = server;
174 } 176 }
175 177
176 public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)//EndPoint packetSender) 178 public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)//EndPoint packetSender)
diff --git a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs
index a055339..9839b0c 100644
--- a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs
+++ b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs
@@ -232,5 +232,22 @@ namespace SimpleApp
232 public void Close() 232 public void Close()
233 { 233 {
234 } 234 }
235
236 private uint m_circuitCode;
237 public uint CircuitCode
238 {
239 get
240 {
241 return m_circuitCode;
242 }
243 set
244 {
245 m_circuitCode = value;
246 }
247 }
248
249 public event System.Action<IClientAPI> OnLogout;
250
251 public event System.Action<IClientAPI> OnConnectionClosed;
235 } 252 }
236} 253}