aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorlbsa712007-09-18 13:29:16 +0000
committerlbsa712007-09-18 13:29:16 +0000
commit70d9cec3b5064d874f8b9622804c964beeac5f0d (patch)
tree29d4ae5a6082ea509f5c92a50582bd9b365c7a0f /OpenSim
parent* Handlerized ViewerEffect (diff)
downloadopensim-SC_OLD-70d9cec3b5064d874f8b9622804c964beeac5f0d.zip
opensim-SC_OLD-70d9cec3b5064d874f8b9622804c964beeac5f0d.tar.gz
opensim-SC_OLD-70d9cec3b5064d874f8b9622804c964beeac5f0d.tar.bz2
opensim-SC_OLD-70d9cec3b5064d874f8b9622804c964beeac5f0d.tar.xz
* Yet some more connectivity restructuring
* We now have CloseAllAgents( circuit ) and CloseAllCircuits( agentId ) for great justice ( but alas, still only closing on one single scene - be brave! ) * Login and ConnectionClosed now eventified and moveified awayified * Killed off unused NullClientAPI * Now the client is almost only responsible for its own closing. ( I will get that scene out of there ) * Lookin' good!
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Framework/General/ClientManager.cs38
-rw-r--r--OpenSim/Framework/General/Interfaces/IClientAPI.cs9
-rw-r--r--OpenSim/Framework/General/NullClientAPI.cs183
-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
10 files changed, 120 insertions, 231 deletions
diff --git a/OpenSim/Framework/General/ClientManager.cs b/OpenSim/Framework/General/ClientManager.cs
index 274a2d3..b032849 100644
--- a/OpenSim/Framework/General/ClientManager.cs
+++ b/OpenSim/Framework/General/ClientManager.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
3using System.Text; 3using System.Text;
4using libsecondlife.Packets; 4using libsecondlife.Packets;
5using OpenSim.Framework.Interfaces; 5using OpenSim.Framework.Interfaces;
6using libsecondlife;
6 7
7namespace OpenSim.Framework 8namespace OpenSim.Framework
8{ 9{
@@ -24,7 +25,7 @@ namespace OpenSim.Framework
24 m_clients = new Dictionary<uint, IClientAPI>(); 25 m_clients = new Dictionary<uint, IClientAPI>();
25 } 26 }
26 27
27 public void Remove(uint id) 28 private void Remove(uint id)
28 { 29 {
29 m_clients.Remove(id); 30 m_clients.Remove(id);
30 } 31 }
@@ -44,19 +45,46 @@ namespace OpenSim.Framework
44 } 45 }
45 } 46 }
46 47
47 public void ConnectionClosed(uint circuitCode) 48 public void CloseAllAgents(uint circuitCode)
48 { 49 {
49 IClientAPI client; 50 IClientAPI client;
50 51
51 if (m_clients.TryGetValue(circuitCode, out client)) 52 if (m_clients.TryGetValue(circuitCode, out client))
52 { 53 {
53 m_clients.Remove(circuitCode); 54 CloseAllCircuits(client.AgentId);
54 client.Close(); 55 }
56 }
57
58 public void CloseAllCircuits( LLUUID agentId )
59 {
60 uint[] circuits = GetAllCircuits(agentId);
61 foreach (uint circuit in circuits )
62 {
63 IClientAPI client;
64 if (m_clients.TryGetValue(circuit, out client))
65 {
66 Remove(circuit);
67 client.Close();
68 }
69 }
70 }
71
72 private uint[] GetAllCircuits(LLUUID agentId)
73 {
74 List<uint> circuits = new List<uint>();
55 75
56 // TODO: Now remove all local childagents too 76 foreach (KeyValuePair<uint, IClientAPI> pair in m_clients)
77 {
78 if( pair.Value.AgentId == agentId )
79 {
80 circuits.Add( pair.Key );
81 }
57 } 82 }
83
84 return circuits.ToArray();
58 } 85 }
59 86
87
60 public void ViewerEffectHandler(IClientAPI sender, ViewerEffectPacket.EffectBlock[] effectBlock) 88 public void ViewerEffectHandler(IClientAPI sender, ViewerEffectPacket.EffectBlock[] effectBlock)
61 { 89 {
62 ViewerEffectPacket packet = new ViewerEffectPacket(); 90 ViewerEffectPacket packet = new ViewerEffectPacket();
diff --git a/OpenSim/Framework/General/Interfaces/IClientAPI.cs b/OpenSim/Framework/General/Interfaces/IClientAPI.cs
index 9c0771f..5fd5adf 100644
--- a/OpenSim/Framework/General/Interfaces/IClientAPI.cs
+++ b/OpenSim/Framework/General/Interfaces/IClientAPI.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*/
28using System;
28using System.Collections.Generic; 29using System.Collections.Generic;
29using System.Net; 30using System.Net;
30using libsecondlife; 31using libsecondlife;
@@ -192,6 +193,12 @@ namespace OpenSim.Framework.Interfaces
192 get; 193 get;
193 } 194 }
194 195
196 uint CircuitCode
197 {
198 get;
199 set;
200 }
201
195 void OutPacket(Packet newPack); 202 void OutPacket(Packet newPack);
196 void SendWearables(AvatarWearable[] wearables); 203 void SendWearables(AvatarWearable[] wearables);
197 void SendAppearance(LLUUID agentID, byte[] visualParams, byte[] textureEntry); 204 void SendAppearance(LLUUID agentID, byte[] visualParams, byte[] textureEntry);
@@ -245,5 +252,7 @@ namespace OpenSim.Framework.Interfaces
245 void InPacket(Packet NewPack); 252 void InPacket(Packet NewPack);
246 void Close(); 253 void Close();
247 event ViewerEffectEventHandler OnViewerEffect; 254 event ViewerEffectEventHandler OnViewerEffect;
255 event Action<IClientAPI> OnLogout;
256 event Action<IClientAPI> OnConnectionClosed;
248 } 257 }
249} 258}
diff --git a/OpenSim/Framework/General/NullClientAPI.cs b/OpenSim/Framework/General/NullClientAPI.cs
deleted file mode 100644
index 2fe46d6..0000000
--- a/OpenSim/Framework/General/NullClientAPI.cs
+++ /dev/null
@@ -1,183 +0,0 @@
1using System.Collections.Generic;
2using System.Net;
3using OpenSim.Framework.Interfaces;
4using OpenSim.Framework.Types;
5using OpenSim.Framework.Data;
6using libsecondlife;
7using libsecondlife.Packets;
8
9
10namespace OpenSim.Framework
11{
12 public class NullClientAPI : IClientAPI
13 {
14#pragma warning disable 67
15 public event ImprovedInstantMessage OnInstantMessage;
16 public event ChatFromViewer OnChatFromViewer;
17 public event RezObject OnRezObject;
18 public event ModifyTerrain OnModifyTerrain;
19 public event SetAppearance OnSetAppearance;
20 public event StartAnim OnStartAnim;
21 public event LinkObjects OnLinkObjects;
22 public event RequestMapBlocks OnRequestMapBlocks;
23 public event TeleportLocationRequest OnTeleportLocationRequest;
24 public event DisconnectUser OnDisconnectUser;
25 public event RequestAvatarProperties OnRequestAvatarProperties;
26
27 public event GenericCall4 OnDeRezObject;
28 public event GenericCall OnRegionHandShakeReply;
29 public event GenericCall OnRequestWearables;
30 public event GenericCall2 OnCompleteMovementToRegion;
31 public event UpdateAgent OnAgentUpdate;
32 public event GenericCall OnRequestAvatarsData;
33 public event AddNewPrim OnAddPrim;
34 public event ObjectDuplicate OnObjectDuplicate;
35 public event UpdateVector OnGrabObject;
36 public event ObjectSelect OnDeGrabObject;
37 public event MoveObject OnGrabUpdate;
38
39 public event UpdateShape OnUpdatePrimShape;
40 public event ObjectExtraParams OnUpdateExtraParams;
41 public event ObjectSelect OnObjectSelect;
42 public event GenericCall7 OnObjectDescription;
43 public event GenericCall7 OnObjectName;
44 public event UpdatePrimFlags OnUpdatePrimFlags;
45 public event UpdatePrimTexture OnUpdatePrimTexture;
46 public event UpdateVector OnUpdatePrimGroupPosition;
47 public event UpdateVector OnUpdatePrimSinglePosition;
48 public event UpdatePrimRotation OnUpdatePrimGroupRotation;
49 public event UpdatePrimSingleRotation OnUpdatePrimSingleRotation;
50 public event UpdatePrimGroupRotation OnUpdatePrimGroupMouseRotation;
51 public event UpdateVector OnUpdatePrimScale;
52 public event StatusChange OnChildAgentStatus;
53 public event GenericCall2 OnStopMovement;
54 public event GenericCall6 OnRemoveAvatar;
55 public event ViewerEffectEventHandler OnViewerEffect;
56
57 public event CreateNewInventoryItem OnCreateNewInventoryItem;
58 public event CreateInventoryFolder OnCreateNewInventoryFolder;
59 public event FetchInventoryDescendents OnFetchInventoryDescendents;
60 public event FetchInventory OnFetchInventory;
61 public event RequestTaskInventory OnRequestTaskInventory;
62 public event UpdateInventoryItemTransaction OnUpdateInventoryItem;
63 public event UDPAssetUploadRequest OnAssetUploadRequest;
64 public event XferReceive OnXferReceive;
65 public event RequestXfer OnRequestXfer;
66 public event ConfirmXfer OnConfirmXfer;
67 public event RezScript OnRezScript;
68 public event UpdateTaskInventory OnUpdateTaskInventory;
69 public event RemoveTaskInventory OnRemoveTaskItem;
70
71 public event UUIDNameRequest OnNameFromUUIDRequest;
72
73 public event ParcelPropertiesRequest OnParcelPropertiesRequest;
74 public event ParcelDivideRequest OnParcelDivideRequest;
75 public event ParcelJoinRequest OnParcelJoinRequest;
76 public event ParcelPropertiesUpdateRequest OnParcelPropertiesUpdateRequest;
77 public event ParcelSelectObjects OnParcelSelectObjects;
78 public event ParcelObjectOwnerRequest OnParcelObjectOwnerRequest;
79 public event ObjectDeselect OnObjectDeselect;
80
81
82 public event EstateOwnerMessageRequest OnEstateOwnerMessage;
83#pragma warning restore 67
84
85 private LLUUID m_uuid = LLUUID.Random();
86 public virtual LLVector3 StartPos
87 {
88 get { return new LLVector3(); }
89 set { }
90 }
91
92 public virtual LLUUID AgentId
93 {
94 get { return m_uuid; }
95 }
96
97 public LLUUID SessionId
98 {
99 get { return LLUUID.Zero; }
100 }
101
102 public virtual string FirstName
103 {
104 get { return ""; }
105 }
106
107 public virtual string LastName
108 {
109 get { return ""; }
110 }
111
112 public NullClientAPI()
113 {
114 }
115
116 public virtual void OutPacket(Packet newPack){}
117 public virtual void SendWearables(AvatarWearable[] wearables){}
118 public virtual void SendAppearance(LLUUID agentID, byte[] visualParams, byte[] textureEntry) { }
119 public virtual void SendStartPingCheck(byte seq){}
120 public virtual void SendKillObject(ulong regionHandle, uint localID){}
121 public virtual void SendAnimation(LLUUID animID, int seq, LLUUID sourceAgentId){}
122 public virtual void SendRegionHandshake(RegionInfo regionInfo){}
123 public virtual void SendChatMessage(string message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID) { }
124 public virtual void SendChatMessage(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID){}
125 public virtual void SendInstantMessage(LLUUID fromAgent, LLUUID fromAgentSession, string message, LLUUID toAgent, LLUUID imSessionID, string fromName, byte dialog, uint timeStamp){}
126 public virtual void SendLayerData(float[] map){}
127 public virtual void SendLayerData(int px, int py, float[] map){}
128 public virtual void MoveAgentIntoRegion(RegionInfo regInfo, LLVector3 pos, LLVector3 look){}
129 public virtual void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint){}
130 public virtual AgentCircuitData RequestClientInfo() { return new AgentCircuitData(); }
131 public virtual void CrossRegion(ulong newRegionHandle, LLVector3 pos, LLVector3 lookAt, IPEndPoint newRegionExternalEndPoint, string capsURL){}
132 public virtual void SendMapBlock(List<MapBlockData> mapBlocks){}
133 public virtual void SendLocalTeleport(LLVector3 position, LLVector3 lookAt, uint flags){}
134 public virtual void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, uint locationID, uint flags, string capsURL){}
135 public virtual void SendTeleportCancel(){}
136 public virtual void SendTeleportLocationStart(){}
137 public virtual void SendMoneyBalance(LLUUID transaction, bool success, byte[] description, int balance){}
138
139 public virtual void SendAvatarData(ulong regionHandle, string firstName, string lastName, LLUUID avatarID, uint avatarLocalID, LLVector3 Pos, byte[] textureEntry){}
140 public virtual void SendAvatarTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLVector3 velocity, LLQuaternion rotation){}
141 public virtual void SendCoarseLocationUpdate(List<LLVector3> CoarseLocations) { }
142
143 public virtual void AttachObject(uint localID, LLQuaternion rotation, byte attachPoint){}
144 public virtual void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, uint flags, LLUUID objectID, LLUUID ownerID, string text, uint parentID, byte[] particleSystem, LLQuaternion rotation){}
145 public virtual void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLQuaternion rotation){}
146
147 public virtual void SendInventoryFolderDetails(LLUUID ownerID, LLUUID folderID, List<InventoryItemBase> items){}
148 public virtual void SendInventoryItemDetails(LLUUID ownerID, InventoryItemBase item){}
149 public virtual void SendInventoryItemUpdate(InventoryItemBase Item) { }
150 public virtual void SendRemoveInventoryItem(LLUUID itemID) { }
151 public virtual void SendTaskInventory(LLUUID taskID, short serial, byte[] fileName) { }
152 public virtual void SendXferPacket(ulong xferID, uint packet, byte[] data) { }
153
154 public virtual void SendPreLoadSound(LLUUID objectID, LLUUID ownerID, LLUUID soundID) { }
155 public virtual void SendPlayAttachedSound(LLUUID soundID, LLUUID objectID, LLUUID ownerID, float gain, byte flags) { }
156
157 public virtual void SendNameReply(LLUUID profileId, string firstname, string lastname){}
158 public void SendAlertMessage(string message) { }
159 public void SendAgentAlertMessage(string message, bool modal) { }
160 public void SendLoadURL(string objectname, LLUUID objectID, LLUUID ownerID, bool groupOwned, string message, string url) { }
161
162
163 public bool AddMoney(int debit)
164 {
165 return false;
166 }
167
168 public void SendViewerTime(int phase) { }
169 public void SendAvatarProperties(LLUUID avatarID, string aboutText, string bornOn, string charterMember, string flAbout, uint flags, LLUUID flImageID, LLUUID imageID, string profileURL, LLUUID partnerID) { }
170 public void SetDebug(int newDebug) { }
171
172 public void InPacket(Packet NewPack)
173 {
174 }
175
176 public void Close()
177 {
178 }
179
180
181 }
182}
183
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}