aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorlbsa712007-09-18 12:13:44 +0000
committerlbsa712007-09-18 12:13:44 +0000
commit0bac4b430c264741b7f9e63b5d8fb781ba306c68 (patch)
tree8106614d6608aeb82b8d455ed95a01725376d9a7 /OpenSim/Region
parent* Replaced usage of ClientView with IClientAPI (diff)
downloadopensim-SC-0bac4b430c264741b7f9e63b5d8fb781ba306c68.zip
opensim-SC-0bac4b430c264741b7f9e63b5d8fb781ba306c68.tar.gz
opensim-SC-0bac4b430c264741b7f9e63b5d8fb781ba306c68.tar.bz2
opensim-SC-0bac4b430c264741b7f9e63b5d8fb781ba306c68.tar.xz
* Handlerized ViewerEffect
* Now there-is-only-client-manager * First step towards moving Logout and ConnectionClosed out of Client and into something else (which will let us get rid of ClientView reference to ClientManager * General posititvity, peace, love and understanding
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/ClientStack/ClientView.API.cs1
-rw-r--r--OpenSim/Region/ClientStack/ClientView.PacketHandlers.cs44
-rw-r--r--OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs13
-rw-r--r--OpenSim/Region/ClientStack/ClientView.cs20
-rw-r--r--OpenSim/Region/ClientStack/PacketServer.cs28
-rw-r--r--OpenSim/Region/ClientStack/UDPServer.cs2
-rw-r--r--OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs3
7 files changed, 53 insertions, 58 deletions
diff --git a/OpenSim/Region/ClientStack/ClientView.API.cs b/OpenSim/Region/ClientStack/ClientView.API.cs
index 9d5a9e8..a15a964 100644
--- a/OpenSim/Region/ClientStack/ClientView.API.cs
+++ b/OpenSim/Region/ClientStack/ClientView.API.cs
@@ -42,6 +42,7 @@ namespace OpenSim.Region.ClientStack
42{ 42{
43 partial class ClientView 43 partial class ClientView
44 { 44 {
45 public event ViewerEffectEventHandler OnViewerEffect;
45 public event ImprovedInstantMessage OnInstantMessage; 46 public event ImprovedInstantMessage OnInstantMessage;
46 public event ChatFromViewer OnChatFromViewer; 47 public event ChatFromViewer OnChatFromViewer;
47 public event RezObject OnRezObject; 48 public event RezObject OnRezObject;
diff --git a/OpenSim/Region/ClientStack/ClientView.PacketHandlers.cs b/OpenSim/Region/ClientStack/ClientView.PacketHandlers.cs
index 71fea0d..65ad431 100644
--- a/OpenSim/Region/ClientStack/ClientView.PacketHandlers.cs
+++ b/OpenSim/Region/ClientStack/ClientView.PacketHandlers.cs
@@ -37,13 +37,28 @@ namespace OpenSim.Region.ClientStack
37 protected virtual void RegisterLocalPacketHandlers() 37 protected virtual void RegisterLocalPacketHandlers()
38 { 38 {
39 this.AddLocalPacketHandler(PacketType.LogoutRequest, this.Logout); 39 this.AddLocalPacketHandler(PacketType.LogoutRequest, this.Logout);
40 this.AddLocalPacketHandler(PacketType.ViewerEffect, this.HandleViewerEffect);
40 this.AddLocalPacketHandler(PacketType.AgentCachedTexture, this.AgentTextureCached); 41 this.AddLocalPacketHandler(PacketType.AgentCachedTexture, this.AgentTextureCached);
41 this.AddLocalPacketHandler(PacketType.MultipleObjectUpdate, this.MultipleObjUpdate); 42 this.AddLocalPacketHandler(PacketType.MultipleObjectUpdate, this.MultipleObjUpdate);
42 } 43 }
43 44
44 protected virtual bool Logout(IClientAPI simClient, Packet packet) 45 private bool HandleViewerEffect(IClientAPI sender, Packet Pack)
45 { 46 {
46 MainLog.Instance.Verbose( "OpenSimClient.cs:ProcessInPacket() - Got a logout request"); 47 ViewerEffectPacket viewer = (ViewerEffectPacket)Pack;
48
49 if( OnViewerEffect != null )
50 {
51 OnViewerEffect(sender, viewer.Effect);
52 }
53
54 return true;
55 }
56
57 protected virtual bool Logout(IClientAPI client, Packet packet)
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");
47 //send reply to let the client logout 62 //send reply to let the client logout
48 LogoutReplyPacket logReply = new LogoutReplyPacket(); 63 LogoutReplyPacket logReply = new LogoutReplyPacket();
49 logReply.AgentData.AgentID = this.AgentId; 64 logReply.AgentData.AgentID = this.AgentId;
@@ -52,8 +67,9 @@ namespace OpenSim.Region.ClientStack
52 logReply.InventoryData[0] = new LogoutReplyPacket.InventoryDataBlock(); 67 logReply.InventoryData[0] = new LogoutReplyPacket.InventoryDataBlock();
53 logReply.InventoryData[0].ItemID = LLUUID.Zero; 68 logReply.InventoryData[0].ItemID = LLUUID.Zero;
54 OutPacket(logReply); 69 OutPacket(logReply);
55 // 70 //
56 this.KillClient(); 71 this.Close();
72
57 return true; 73 return true;
58 } 74 }
59 75
@@ -81,7 +97,7 @@ namespace OpenSim.Region.ClientStack
81 protected bool MultipleObjUpdate(IClientAPI simClient, Packet packet) 97 protected bool MultipleObjUpdate(IClientAPI simClient, Packet packet)
82 { 98 {
83 MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket)packet; 99 MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket)packet;
84 // System.Console.WriteLine("new multi update packet " + multipleupdate.ToString()); 100 // System.Console.WriteLine("new multi update packet " + multipleupdate.ToString());
85 for (int i = 0; i < multipleupdate.ObjectData.Length; i++) 101 for (int i = 0; i < multipleupdate.ObjectData.Length; i++)
86 { 102 {
87 #region position 103 #region position
@@ -99,7 +115,7 @@ namespace OpenSim.Region.ClientStack
99 if (OnUpdatePrimSinglePosition != null) 115 if (OnUpdatePrimSinglePosition != null)
100 { 116 {
101 libsecondlife.LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0); 117 libsecondlife.LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0);
102 // System.Console.WriteLine("new movement position is " + pos.X + " , " + pos.Y + " , " + pos.Z); 118 // System.Console.WriteLine("new movement position is " + pos.X + " , " + pos.Y + " , " + pos.Z);
103 OnUpdatePrimSinglePosition(multipleupdate.ObjectData[i].ObjectLocalID, pos, this); 119 OnUpdatePrimSinglePosition(multipleupdate.ObjectData[i].ObjectLocalID, pos, this);
104 } 120 }
105 } 121 }
@@ -128,7 +144,7 @@ namespace OpenSim.Region.ClientStack
128 if (OnUpdatePrimGroupRotation != null) 144 if (OnUpdatePrimGroupRotation != null)
129 { 145 {
130 libsecondlife.LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 0, true); 146 libsecondlife.LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 0, true);
131 // Console.WriteLine("new rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W); 147 // Console.WriteLine("new rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W);
132 OnUpdatePrimGroupRotation(multipleupdate.ObjectData[i].ObjectLocalID, rot, this); 148 OnUpdatePrimGroupRotation(multipleupdate.ObjectData[i].ObjectLocalID, rot, this);
133 } 149 }
134 } 150 }
@@ -139,7 +155,7 @@ namespace OpenSim.Region.ClientStack
139 libsecondlife.LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0); 155 libsecondlife.LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0);
140 libsecondlife.LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 12, true); 156 libsecondlife.LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 12, true);
141 //Console.WriteLine("new rotation position is " + pos.X + " , " + pos.Y + " , " + pos.Z); 157 //Console.WriteLine("new rotation position is " + pos.X + " , " + pos.Y + " , " + pos.Z);
142 // Console.WriteLine("new rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W); 158 // Console.WriteLine("new rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W);
143 OnUpdatePrimGroupMouseRotation(multipleupdate.ObjectData[i].ObjectLocalID, pos, rot, this); 159 OnUpdatePrimGroupMouseRotation(multipleupdate.ObjectData[i].ObjectLocalID, pos, rot, this);
144 } 160 }
145 } 161 }
@@ -164,10 +180,10 @@ namespace OpenSim.Region.ClientStack
164 if (OnUpdatePrimScale != null) 180 if (OnUpdatePrimScale != null)
165 { 181 {
166 libsecondlife.LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12); 182 libsecondlife.LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12);
167 // Console.WriteLine("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z ); 183 // Console.WriteLine("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z );
168 OnUpdatePrimScale(multipleupdate.ObjectData[i].ObjectLocalID, scale, this); 184 OnUpdatePrimScale(multipleupdate.ObjectData[i].ObjectLocalID, scale, this);
169 libsecondlife.LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0); 185 libsecondlife.LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0);
170 OnUpdatePrimSinglePosition(multipleupdate.ObjectData[i].ObjectLocalID, pos, this); 186 OnUpdatePrimSinglePosition(multipleupdate.ObjectData[i].ObjectLocalID, pos, this);
171 } 187 }
172 } 188 }
173 else if (multipleupdate.ObjectData[i].Type == 5)//single prim scale from object tab 189 else if (multipleupdate.ObjectData[i].Type == 5)//single prim scale from object tab
@@ -175,7 +191,7 @@ namespace OpenSim.Region.ClientStack
175 if (OnUpdatePrimScale != null) 191 if (OnUpdatePrimScale != null)
176 { 192 {
177 libsecondlife.LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12); 193 libsecondlife.LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12);
178 // Console.WriteLine("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z); 194 // Console.WriteLine("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
179 OnUpdatePrimScale(multipleupdate.ObjectData[i].ObjectLocalID, scale, this); 195 OnUpdatePrimScale(multipleupdate.ObjectData[i].ObjectLocalID, scale, this);
180 } 196 }
181 } 197 }
@@ -184,7 +200,7 @@ namespace OpenSim.Region.ClientStack
184 if (OnUpdatePrimScale != null) 200 if (OnUpdatePrimScale != null)
185 { 201 {
186 libsecondlife.LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12); 202 libsecondlife.LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12);
187 // Console.WriteLine("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z); 203 // Console.WriteLine("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
188 OnUpdatePrimScale(multipleupdate.ObjectData[i].ObjectLocalID, scale, this); 204 OnUpdatePrimScale(multipleupdate.ObjectData[i].ObjectLocalID, scale, this);
189 } 205 }
190 } 206 }
diff --git a/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs b/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs
index 95ce3c5..009ddac 100644
--- a/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs
+++ b/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs
@@ -75,19 +75,6 @@ namespace OpenSim.Region.ClientStack
75 75
76 switch (Pack.Type) 76 switch (Pack.Type)
77 { 77 {
78 case PacketType.ViewerEffect:
79 ViewerEffectPacket viewer = (ViewerEffectPacket)Pack;
80 foreach (IClientAPI client in m_clientThreads.Values)
81 {
82 if (client.AgentId != this.AgentId)
83 {
84 viewer.AgentData.AgentID = client.AgentId;
85 viewer.AgentData.SessionID = client.SessionId;
86 client.OutPacket(viewer);
87 }
88 }
89 break;
90
91 #region Scene/Avatar 78 #region Scene/Avatar
92 case PacketType.AvatarPropertiesRequest: 79 case PacketType.AvatarPropertiesRequest:
93 AvatarPropertiesRequestPacket avatarProperties = (AvatarPropertiesRequestPacket)Pack; 80 AvatarPropertiesRequestPacket avatarProperties = (AvatarPropertiesRequestPacket)Pack;
diff --git a/OpenSim/Region/ClientStack/ClientView.cs b/OpenSim/Region/ClientStack/ClientView.cs
index 2bff88a..f8ac1d8 100644
--- a/OpenSim/Region/ClientStack/ClientView.cs
+++ b/OpenSim/Region/ClientStack/ClientView.cs
@@ -71,7 +71,7 @@ namespace OpenSim.Region.ClientStack
71 private LLUUID newAssetFolder = LLUUID.Zero; 71 private LLUUID newAssetFolder = LLUUID.Zero;
72 private int debug = 0; 72 private int debug = 0;
73 protected IScene m_scene; 73 protected IScene m_scene;
74 private Dictionary<uint, IClientAPI> m_clientThreads; 74 private ClientManager m_clientManager;
75 private AssetCache m_assetCache; 75 private AssetCache m_assetCache;
76 // private InventoryCache m_inventoryCache; 76 // private InventoryCache m_inventoryCache;
77 private int cachedtextureserial = 0; 77 private int cachedtextureserial = 0;
@@ -83,12 +83,12 @@ namespace OpenSim.Region.ClientStack
83 private int probesWithNoIngressPackets = 0; 83 private int probesWithNoIngressPackets = 0;
84 private int lastPacketsReceived = 0; 84 private int lastPacketsReceived = 0;
85 85
86 public ClientView(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, Dictionary<uint, IClientAPI> clientThreads, IScene scene, AssetCache assetCache, PacketServer packServer, AgentCircuitManager authenSessions) 86 public ClientView(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, ClientManager clientManager, IScene scene, AssetCache assetCache, PacketServer packServer, AgentCircuitManager authenSessions)
87 { 87 {
88 m_moneyBalance = 1000; 88 m_moneyBalance = 1000;
89 89
90 m_scene = scene; 90 m_scene = scene;
91 m_clientThreads = clientThreads; 91 m_clientManager = clientManager;
92 m_assetCache = assetCache; 92 m_assetCache = assetCache;
93 93
94 m_networkServer = packServer; 94 m_networkServer = packServer;
@@ -127,24 +127,17 @@ namespace OpenSim.Region.ClientStack
127 127
128 # region Client Methods 128 # region Client Methods
129 129
130 public void KillClient() 130 public void Close()
131 { 131 {
132 clientPingTimer.Stop(); 132 clientPingTimer.Stop();
133 133
134 m_scene.RemoveClient(this.AgentId); 134 m_scene.RemoveClient(this.AgentId);
135 135
136 m_clientThreads.Remove(this.CircuitCode); 136 m_clientManager.Remove(this.CircuitCode); // TODO: Move out and delete ref to clientmanager.
137 m_networkServer.RemoveClientCircuit(this.CircuitCode); 137 m_networkServer.RemoveClientCircuit(this.CircuitCode);
138 this.ClientThread.Abort(); 138 this.ClientThread.Abort();
139 } 139 }
140 140
141 public void ConnectionClosed()
142 {
143 clientPingTimer.Stop();
144 m_clientThreads.Remove(this.CircuitCode);
145 m_networkServer.RemoveClientCircuit(this.CircuitCode);
146 this.ClientThread.Abort();
147 }
148 #endregion 141 #endregion
149 142
150 # region Packet Handling 143 # region Packet Handling
@@ -259,7 +252,8 @@ namespace OpenSim.Region.ClientStack
259 probesWithNoIngressPackets++; 252 probesWithNoIngressPackets++;
260 if (probesWithNoIngressPackets > 30) 253 if (probesWithNoIngressPackets > 30)
261 { 254 {
262 this.KillClient(); 255 // Refactor out this into an OnConnectionClosed so the ClientManager can clean up
256 this.Close();
263 } 257 }
264 else 258 else
265 { 259 {
diff --git a/OpenSim/Region/ClientStack/PacketServer.cs b/OpenSim/Region/ClientStack/PacketServer.cs
index 481e445..bceeeb3 100644
--- a/OpenSim/Region/ClientStack/PacketServer.cs
+++ b/OpenSim/Region/ClientStack/PacketServer.cs
@@ -40,7 +40,6 @@ namespace OpenSim.Region.ClientStack
40 { 40 {
41 private ClientStackNetworkHandler _networkHandler; 41 private ClientStackNetworkHandler _networkHandler;
42 private IScene _localScene; 42 private IScene _localScene;
43 public Dictionary<uint, IClientAPI> ClientThreads = new Dictionary<uint, IClientAPI>();
44 private ClientManager m_clientManager = new ClientManager(); 43 private ClientManager m_clientManager = new ClientManager();
45 public ClientManager ClientManager 44 public ClientManager ClientManager
46 { 45 {
@@ -66,20 +65,14 @@ namespace OpenSim.Region.ClientStack
66 /// </summary> 65 /// </summary>
67 /// <param name="circuitCode"></param> 66 /// <param name="circuitCode"></param>
68 /// <param name="packet"></param> 67 /// <param name="packet"></param>
69 public virtual void ClientInPacket(uint circuitCode, Packet packet) 68 public virtual void InPacket(uint circuitCode, Packet packet)
70 { 69 {
71 if (this.ClientThreads.ContainsKey(circuitCode)) 70 m_clientManager.InPacket(circuitCode, packet);
72 {
73 ClientThreads[circuitCode].InPacket(packet);
74 }
75 } 71 }
76 72
77 public virtual void ConnectionClosed(uint circuitCode) 73 public virtual void ConnectionClosed(uint circuitCode)
78 { 74 {
79 if (this.ClientThreads.ContainsKey(circuitCode)) 75 m_clientManager.ConnectionClosed(circuitCode);
80 {
81 ClientThreads[circuitCode].ConnectionClosed();
82 }
83 } 76 }
84 77
85 /// <summary> 78 /// <summary>
@@ -129,9 +122,9 @@ namespace OpenSim.Region.ClientStack
129 122
130 } 123 }
131 124
132 protected virtual IClientAPI CreateNewClient(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, Dictionary<uint, IClientAPI> clientThreads, IScene scene, AssetCache assetCache, PacketServer packServer, AgentCircuitManager authenSessions) 125 protected virtual IClientAPI CreateNewClient(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, ClientManager clientManager, IScene scene, AssetCache assetCache, PacketServer packServer, AgentCircuitManager authenSessions)
133 { 126 {
134 return new ClientView(remoteEP, initialcirpack, clientThreads, scene, assetCache, packServer, authenSessions ); 127 return new ClientView(remoteEP, initialcirpack, clientManager, scene, assetCache, packServer, authenSessions );
135 } 128 }
136 129
137 /// <summary> 130 /// <summary>
@@ -146,15 +139,18 @@ namespace OpenSim.Region.ClientStack
146 public virtual bool AddNewClient(EndPoint epSender, UseCircuitCodePacket useCircuit, AssetCache assetCache, AgentCircuitManager authenticateSessionsClass) 139 public virtual bool AddNewClient(EndPoint epSender, UseCircuitCodePacket useCircuit, AssetCache assetCache, AgentCircuitManager authenticateSessionsClass)
147 { 140 {
148 IClientAPI newuser = 141 IClientAPI newuser =
149 CreateNewClient(epSender, useCircuit, ClientThreads, _localScene, assetCache, this, 142 CreateNewClient(epSender, useCircuit, m_clientManager, _localScene, assetCache, this,
150 authenticateSessionsClass); 143 authenticateSessionsClass);
151 144
152 this.ClientThreads.Add(useCircuit.CircuitCode.Code, newuser); 145 this.m_clientManager.Add(useCircuit.CircuitCode.Code, newuser);
153 this.m_clientManager.Add(useCircuit.CircuitCode.Code, (IClientAPI)newuser); 146
147 newuser.OnViewerEffect += m_clientManager.ViewerEffectHandler;
154 148
155 return true; 149 return true;
156 } 150 }
157 151
152
153
158 /// <summary> 154 /// <summary>
159 /// 155 ///
160 /// </summary> 156 /// </summary>
diff --git a/OpenSim/Region/ClientStack/UDPServer.cs b/OpenSim/Region/ClientStack/UDPServer.cs
index 10ae6ee..efc9c87 100644
--- a/OpenSim/Region/ClientStack/UDPServer.cs
+++ b/OpenSim/Region/ClientStack/UDPServer.cs
@@ -126,7 +126,7 @@ namespace OpenSim.Region.ClientStack
126 if (this.clientCircuits.ContainsKey(epSender)) 126 if (this.clientCircuits.ContainsKey(epSender))
127 { 127 {
128 //if so then send packet to the packetserver 128 //if so then send packet to the packetserver
129 this._packetServer.ClientInPacket(this.clientCircuits[epSender], packet); 129 this._packetServer.InPacket(this.clientCircuits[epSender], packet);
130 } 130 }
131 else if (packet.Type == PacketType.UseCircuitCode) 131 else if (packet.Type == PacketType.UseCircuitCode)
132 { 132 {
diff --git a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs
index 72a1e19..a055339 100644
--- a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs
+++ b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs
@@ -43,6 +43,7 @@ namespace SimpleApp
43 public event UpdateVector OnGrabObject; 43 public event UpdateVector OnGrabObject;
44 public event ObjectSelect OnDeGrabObject; 44 public event ObjectSelect OnDeGrabObject;
45 public event MoveObject OnGrabUpdate; 45 public event MoveObject OnGrabUpdate;
46 public event ViewerEffectEventHandler OnViewerEffect;
46 47
47 48
48 public event UpdateShape OnUpdatePrimShape; 49 public event UpdateShape OnUpdatePrimShape;
@@ -228,7 +229,7 @@ namespace SimpleApp
228 { 229 {
229 } 230 }
230 231
231 public void ConnectionClosed() 232 public void Close()
232 { 233 {
233 } 234 }
234 } 235 }