diff options
Diffstat (limited to '')
21 files changed, 561 insertions, 522 deletions
diff --git a/OpenSim.RegionServer/AgentAssetUpload.cs b/OpenSim.RegionServer/AgentAssetUpload.cs index cdf49c5..dd2b2a9 100644 --- a/OpenSim.RegionServer/AgentAssetUpload.cs +++ b/OpenSim.RegionServer/AgentAssetUpload.cs | |||
@@ -12,11 +12,11 @@ namespace OpenSim | |||
12 | public class AgentAssetUpload | 12 | public class AgentAssetUpload |
13 | { | 13 | { |
14 | private Dictionary<LLUUID, AssetTransaction> transactions = new Dictionary<LLUUID, AssetTransaction>(); | 14 | private Dictionary<LLUUID, AssetTransaction> transactions = new Dictionary<LLUUID, AssetTransaction>(); |
15 | private SimClient ourClient; | 15 | private ClientView ourClient; |
16 | private AssetCache m_assetCache; | 16 | private AssetCache m_assetCache; |
17 | private InventoryCache m_inventoryCache; | 17 | private InventoryCache m_inventoryCache; |
18 | 18 | ||
19 | public AgentAssetUpload(SimClient client, AssetCache assetCache, InventoryCache inventoryCache) | 19 | public AgentAssetUpload(ClientView client, AssetCache assetCache, InventoryCache inventoryCache) |
20 | { | 20 | { |
21 | this.ourClient = client; | 21 | this.ourClient = client; |
22 | m_assetCache = assetCache; | 22 | m_assetCache = assetCache; |
diff --git a/OpenSim.RegionServer/Assets/AssetCache.cs b/OpenSim.RegionServer/Assets/AssetCache.cs index e8bf292..ccebb24 100644 --- a/OpenSim.RegionServer/Assets/AssetCache.cs +++ b/OpenSim.RegionServer/Assets/AssetCache.cs | |||
@@ -324,7 +324,7 @@ namespace OpenSim.Assets | |||
324 | /// </summary> | 324 | /// </summary> |
325 | /// <param name="userInfo"></param> | 325 | /// <param name="userInfo"></param> |
326 | /// <param name="transferRequest"></param> | 326 | /// <param name="transferRequest"></param> |
327 | public void AddAssetRequest(SimClient userInfo, TransferRequestPacket transferRequest) | 327 | public void AddAssetRequest(ClientView userInfo, TransferRequestPacket transferRequest) |
328 | { | 328 | { |
329 | LLUUID requestID = new LLUUID(transferRequest.TransferInfo.Params, 0); | 329 | LLUUID requestID = new LLUUID(transferRequest.TransferInfo.Params, 0); |
330 | //check to see if asset is in local cache, if not we need to request it from asset server. | 330 | //check to see if asset is in local cache, if not we need to request it from asset server. |
@@ -464,7 +464,7 @@ namespace OpenSim.Assets | |||
464 | /// </summary> | 464 | /// </summary> |
465 | /// <param name="userInfo"></param> | 465 | /// <param name="userInfo"></param> |
466 | /// <param name="imageID"></param> | 466 | /// <param name="imageID"></param> |
467 | public void AddTextureRequest(SimClient userInfo, LLUUID imageID) | 467 | public void AddTextureRequest(ClientView userInfo, LLUUID imageID) |
468 | { | 468 | { |
469 | //check to see if texture is in local cache, if not request from asset server | 469 | //check to see if texture is in local cache, if not request from asset server |
470 | if (!this.Textures.ContainsKey(imageID)) | 470 | if (!this.Textures.ContainsKey(imageID)) |
@@ -517,7 +517,7 @@ namespace OpenSim.Assets | |||
517 | 517 | ||
518 | public class AssetRequest | 518 | public class AssetRequest |
519 | { | 519 | { |
520 | public SimClient RequestUser; | 520 | public ClientView RequestUser; |
521 | public LLUUID RequestAssetID; | 521 | public LLUUID RequestAssetID; |
522 | public AssetInfo AssetInf; | 522 | public AssetInfo AssetInf; |
523 | public TextureImage ImageInfo; | 523 | public TextureImage ImageInfo; |
diff --git a/OpenSim.RegionServer/Assets/InventoryCache.cs b/OpenSim.RegionServer/Assets/InventoryCache.cs index 136ae53..64a7a32 100644 --- a/OpenSim.RegionServer/Assets/InventoryCache.cs +++ b/OpenSim.RegionServer/Assets/InventoryCache.cs | |||
@@ -94,12 +94,12 @@ namespace OpenSim.Assets | |||
94 | } | 94 | } |
95 | } | 95 | } |
96 | 96 | ||
97 | public bool CreateNewInventoryFolder(SimClient remoteClient, LLUUID folderID) | 97 | public bool CreateNewInventoryFolder(ClientView remoteClient, LLUUID folderID) |
98 | { | 98 | { |
99 | return this.CreateNewInventoryFolder(remoteClient, folderID, 0); | 99 | return this.CreateNewInventoryFolder(remoteClient, folderID, 0); |
100 | } | 100 | } |
101 | 101 | ||
102 | public bool CreateNewInventoryFolder(SimClient remoteClient, LLUUID folderID, ushort type) | 102 | public bool CreateNewInventoryFolder(ClientView remoteClient, LLUUID folderID, ushort type) |
103 | { | 103 | { |
104 | bool res = false; | 104 | bool res = false; |
105 | if (folderID != LLUUID.Zero) //don't create a folder with a zero id | 105 | if (folderID != LLUUID.Zero) //don't create a folder with a zero id |
@@ -112,7 +112,7 @@ namespace OpenSim.Assets | |||
112 | return res; | 112 | return res; |
113 | } | 113 | } |
114 | 114 | ||
115 | public bool CreateNewInventoryFolder(SimClient remoteClient, LLUUID folderID, ushort type, string folderName, LLUUID parent) | 115 | public bool CreateNewInventoryFolder(ClientView remoteClient, LLUUID folderID, ushort type, string folderName, LLUUID parent) |
116 | { | 116 | { |
117 | bool res = false; | 117 | bool res = false; |
118 | if (folderID != LLUUID.Zero) //don't create a folder with a zero id | 118 | if (folderID != LLUUID.Zero) //don't create a folder with a zero id |
@@ -125,7 +125,7 @@ namespace OpenSim.Assets | |||
125 | return res; | 125 | return res; |
126 | } | 126 | } |
127 | 127 | ||
128 | public LLUUID AddNewInventoryItem(SimClient remoteClient, LLUUID folderID, OpenSim.Framework.Types.AssetBase asset) | 128 | public LLUUID AddNewInventoryItem(ClientView remoteClient, LLUUID folderID, OpenSim.Framework.Types.AssetBase asset) |
129 | { | 129 | { |
130 | LLUUID newItem = null; | 130 | LLUUID newItem = null; |
131 | if (this._agentsInventory.ContainsKey(remoteClient.AgentID)) | 131 | if (this._agentsInventory.ContainsKey(remoteClient.AgentID)) |
@@ -140,7 +140,7 @@ namespace OpenSim.Assets | |||
140 | 140 | ||
141 | return newItem; | 141 | return newItem; |
142 | } | 142 | } |
143 | public bool DeleteInventoryItem(SimClient remoteClient, LLUUID itemID) | 143 | public bool DeleteInventoryItem(ClientView remoteClient, LLUUID itemID) |
144 | { | 144 | { |
145 | bool res = false; | 145 | bool res = false; |
146 | if (this._agentsInventory.ContainsKey(remoteClient.AgentID)) | 146 | if (this._agentsInventory.ContainsKey(remoteClient.AgentID)) |
@@ -161,7 +161,7 @@ namespace OpenSim.Assets | |||
161 | return res; | 161 | return res; |
162 | } | 162 | } |
163 | 163 | ||
164 | public bool UpdateInventoryItemAsset(SimClient remoteClient, LLUUID itemID, OpenSim.Framework.Types.AssetBase asset) | 164 | public bool UpdateInventoryItemAsset(ClientView remoteClient, LLUUID itemID, OpenSim.Framework.Types.AssetBase asset) |
165 | { | 165 | { |
166 | if (this._agentsInventory.ContainsKey(remoteClient.AgentID)) | 166 | if (this._agentsInventory.ContainsKey(remoteClient.AgentID)) |
167 | { | 167 | { |
@@ -177,7 +177,7 @@ namespace OpenSim.Assets | |||
177 | return false; | 177 | return false; |
178 | } | 178 | } |
179 | 179 | ||
180 | public bool UpdateInventoryItemDetails(SimClient remoteClient, LLUUID itemID, UpdateInventoryItemPacket.InventoryDataBlock packet) | 180 | public bool UpdateInventoryItemDetails(ClientView remoteClient, LLUUID itemID, UpdateInventoryItemPacket.InventoryDataBlock packet) |
181 | { | 181 | { |
182 | if (this._agentsInventory.ContainsKey(remoteClient.AgentID)) | 182 | if (this._agentsInventory.ContainsKey(remoteClient.AgentID)) |
183 | { | 183 | { |
@@ -193,7 +193,7 @@ namespace OpenSim.Assets | |||
193 | return false; | 193 | return false; |
194 | } | 194 | } |
195 | 195 | ||
196 | public void FetchInventoryDescendents(SimClient userInfo, FetchInventoryDescendentsPacket FetchDescend) | 196 | public void FetchInventoryDescendents(ClientView userInfo, FetchInventoryDescendentsPacket FetchDescend) |
197 | { | 197 | { |
198 | if (this._agentsInventory.ContainsKey(userInfo.AgentID)) | 198 | if (this._agentsInventory.ContainsKey(userInfo.AgentID)) |
199 | { | 199 | { |
@@ -250,7 +250,7 @@ namespace OpenSim.Assets | |||
250 | } | 250 | } |
251 | } | 251 | } |
252 | 252 | ||
253 | public void FetchInventory(SimClient userInfo, FetchInventoryPacket FetchItems) | 253 | public void FetchInventory(ClientView userInfo, FetchInventoryPacket FetchItems) |
254 | { | 254 | { |
255 | if (this._agentsInventory.ContainsKey(userInfo.AgentID)) | 255 | if (this._agentsInventory.ContainsKey(userInfo.AgentID)) |
256 | { | 256 | { |
@@ -291,7 +291,7 @@ namespace OpenSim.Assets | |||
291 | } | 291 | } |
292 | } | 292 | } |
293 | 293 | ||
294 | private void SendItemUpdateCreate(SimClient remoteClient, InventoryItem Item) | 294 | private void SendItemUpdateCreate(ClientView remoteClient, InventoryItem Item) |
295 | { | 295 | { |
296 | 296 | ||
297 | UpdateCreateInventoryItemPacket InventoryReply = new UpdateCreateInventoryItemPacket(); | 297 | UpdateCreateInventoryItemPacket InventoryReply = new UpdateCreateInventoryItemPacket(); |
diff --git a/OpenSim.RegionServer/SimClient.Grid.cs b/OpenSim.RegionServer/ClientView.Grid.cs index 493d4d7..a3b191c 100644 --- a/OpenSim.RegionServer/SimClient.Grid.cs +++ b/OpenSim.RegionServer/ClientView.Grid.cs | |||
@@ -18,7 +18,7 @@ using OpenSim.Assets; | |||
18 | 18 | ||
19 | namespace OpenSim | 19 | namespace OpenSim |
20 | { | 20 | { |
21 | public partial class SimClient | 21 | public partial class ClientView |
22 | { | 22 | { |
23 | 23 | ||
24 | public void EnableNeighbours() | 24 | public void EnableNeighbours() |
diff --git a/OpenSim.RegionServer/SimClient.PacketHandlers.cs b/OpenSim.RegionServer/ClientView.PacketHandlers.cs index 62919ba..070c200 100644 --- a/OpenSim.RegionServer/SimClient.PacketHandlers.cs +++ b/OpenSim.RegionServer/ClientView.PacketHandlers.cs | |||
@@ -18,7 +18,7 @@ using OpenSim.Assets; | |||
18 | 18 | ||
19 | namespace OpenSim | 19 | namespace OpenSim |
20 | { | 20 | { |
21 | public partial class SimClient | 21 | public partial class ClientView |
22 | { | 22 | { |
23 | protected virtual void RegisterLocalPacketHandlers() | 23 | protected virtual void RegisterLocalPacketHandlers() |
24 | { | 24 | { |
@@ -27,7 +27,7 @@ namespace OpenSim | |||
27 | this.AddLocalPacketHandler(PacketType.MultipleObjectUpdate, this.MultipleObjUpdate); | 27 | this.AddLocalPacketHandler(PacketType.MultipleObjectUpdate, this.MultipleObjUpdate); |
28 | } | 28 | } |
29 | 29 | ||
30 | protected virtual bool Logout(SimClient simClient, Packet packet) | 30 | protected virtual bool Logout(ClientView simClient, Packet packet) |
31 | { | 31 | { |
32 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "OpenSimClient.cs:ProcessInPacket() - Got a logout request"); | 32 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "OpenSimClient.cs:ProcessInPacket() - Got a logout request"); |
33 | //send reply to let the client logout | 33 | //send reply to let the client logout |
@@ -43,7 +43,7 @@ namespace OpenSim | |||
43 | kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1]; | 43 | kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1]; |
44 | kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock(); | 44 | kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock(); |
45 | kill.ObjectData[0].ID = this.ClientAvatar.localid; | 45 | kill.ObjectData[0].ID = this.ClientAvatar.localid; |
46 | foreach (SimClient client in m_clientThreads.Values) | 46 | foreach (ClientView client in m_clientThreads.Values) |
47 | { | 47 | { |
48 | client.OutPacket(kill); | 48 | client.OutPacket(kill); |
49 | } | 49 | } |
@@ -69,7 +69,7 @@ namespace OpenSim | |||
69 | return true; | 69 | return true; |
70 | } | 70 | } |
71 | 71 | ||
72 | protected bool AgentTextureCached(SimClient simclient, Packet packet) | 72 | protected bool AgentTextureCached(ClientView simclient, Packet packet) |
73 | { | 73 | { |
74 | // Console.WriteLine(packet.ToString()); | 74 | // Console.WriteLine(packet.ToString()); |
75 | AgentCachedTexturePacket chechedtex = (AgentCachedTexturePacket)packet; | 75 | AgentCachedTexturePacket chechedtex = (AgentCachedTexturePacket)packet; |
@@ -90,7 +90,7 @@ namespace OpenSim | |||
90 | return true; | 90 | return true; |
91 | } | 91 | } |
92 | 92 | ||
93 | protected bool MultipleObjUpdate(SimClient simClient, Packet packet) | 93 | protected bool MultipleObjUpdate(ClientView simClient, Packet packet) |
94 | { | 94 | { |
95 | MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket)packet; | 95 | MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket)packet; |
96 | for (int i = 0; i < multipleupdate.ObjectData.Length; i++) | 96 | for (int i = 0; i < multipleupdate.ObjectData.Length; i++) |
diff --git a/OpenSim.RegionServer/SimClient.ProcessPackets.cs b/OpenSim.RegionServer/ClientView.ProcessPackets.cs index c9592c2..0079d96 100644 --- a/OpenSim.RegionServer/SimClient.ProcessPackets.cs +++ b/OpenSim.RegionServer/ClientView.ProcessPackets.cs | |||
@@ -18,9 +18,14 @@ using OpenSim.Assets; | |||
18 | 18 | ||
19 | namespace OpenSim | 19 | namespace OpenSim |
20 | { | 20 | { |
21 | public partial class SimClient | 21 | public partial class ClientView |
22 | { | 22 | { |
23 | protected virtual void ProcessInPacket(Packet Pack) | 23 | public delegate void ChatFromViewer(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID); |
24 | |||
25 | |||
26 | public event ChatFromViewer OnChatFromViewer; | ||
27 | |||
28 | protected override void ProcessInPacket(Packet Pack) | ||
24 | { | 29 | { |
25 | ack_pack(Pack); | 30 | ack_pack(Pack); |
26 | if (debug) | 31 | if (debug) |
@@ -42,6 +47,24 @@ namespace OpenSim | |||
42 | 47 | ||
43 | switch (Pack.Type) | 48 | switch (Pack.Type) |
44 | { | 49 | { |
50 | #region New Event system | ||
51 | case PacketType.ChatFromViewer: | ||
52 | ChatFromViewerPacket inchatpack = (ChatFromViewerPacket)Pack; | ||
53 | if (Util.FieldToString(inchatpack.ChatData.Message) == "") | ||
54 | { | ||
55 | //empty message so don't bother with it | ||
56 | break; | ||
57 | } | ||
58 | string fromName = ClientAvatar.firstname + " " + ClientAvatar.lastname; | ||
59 | byte[] message = inchatpack.ChatData.Message; | ||
60 | byte type = inchatpack.ChatData.Type; | ||
61 | LLVector3 fromPos = ClientAvatar.Pos; | ||
62 | LLUUID fromAgentID = AgentID; | ||
63 | this.OnChatFromViewer(message, type, fromPos, fromName, fromAgentID); | ||
64 | break; | ||
65 | #endregion | ||
66 | |||
67 | #region World/Avatar/Primitive related packets | ||
45 | case PacketType.CompleteAgentMovement: | 68 | case PacketType.CompleteAgentMovement: |
46 | if (this.m_child) this.UpgradeClient(); | 69 | if (this.m_child) this.UpgradeClient(); |
47 | ClientAvatar.CompleteMovement(m_world); | 70 | ClientAvatar.CompleteMovement(m_world); |
@@ -53,13 +76,13 @@ namespace OpenSim | |||
53 | break; | 76 | break; |
54 | case PacketType.AgentWearablesRequest: | 77 | case PacketType.AgentWearablesRequest: |
55 | ClientAvatar.SendInitialAppearance(); | 78 | ClientAvatar.SendInitialAppearance(); |
56 | foreach (SimClient client in m_clientThreads.Values) | 79 | foreach (ClientView client in m_clientThreads.Values) |
57 | { | 80 | { |
58 | if (client.AgentID != this.AgentID) | 81 | if (client.AgentID != this.AgentID) |
59 | { | 82 | { |
60 | ObjectUpdatePacket objupdate = client.ClientAvatar.CreateUpdatePacket(); | 83 | ObjectUpdatePacket objupdate = client.ClientAvatar.CreateUpdatePacket(); |
61 | this.OutPacket(objupdate); | 84 | this.OutPacket(objupdate); |
62 | client.ClientAvatar.SendAppearanceToOtherAgent(this); | 85 | client.ClientAvatar.SendAppearanceToOtherAgent(this.ClientAvatar); |
63 | } | 86 | } |
64 | } | 87 | } |
65 | m_world.GetInitialPrims(this); | 88 | m_world.GetInitialPrims(this); |
@@ -120,18 +143,6 @@ namespace OpenSim | |||
120 | } | 143 | } |
121 | } | 144 | } |
122 | break; | 145 | break; |
123 | case PacketType.RequestImage: | ||
124 | RequestImagePacket imageRequest = (RequestImagePacket)Pack; | ||
125 | for (int i = 0; i < imageRequest.RequestImage.Length; i++) | ||
126 | { | ||
127 | m_assetCache.AddTextureRequest(this, imageRequest.RequestImage[i].Image); | ||
128 | } | ||
129 | break; | ||
130 | case PacketType.TransferRequest: | ||
131 | //Console.WriteLine("OpenSimClient.cs:ProcessInPacket() - Got transfer request"); | ||
132 | TransferRequestPacket transfer = (TransferRequestPacket)Pack; | ||
133 | m_assetCache.AddAssetRequest(this, transfer); | ||
134 | break; | ||
135 | case PacketType.AgentUpdate: | 146 | case PacketType.AgentUpdate: |
136 | ClientAvatar.HandleUpdate((AgentUpdatePacket)Pack); | 147 | ClientAvatar.HandleUpdate((AgentUpdatePacket)Pack); |
137 | break; | 148 | break; |
@@ -158,6 +169,62 @@ namespace OpenSim | |||
158 | } | 169 | } |
159 | } | 170 | } |
160 | break; | 171 | break; |
172 | case PacketType.AgentAnimation: | ||
173 | if (!m_child) | ||
174 | { | ||
175 | AgentAnimationPacket AgentAni = (AgentAnimationPacket)Pack; | ||
176 | for (int i = 0; i < AgentAni.AnimationList.Length; i++) | ||
177 | { | ||
178 | if (AgentAni.AnimationList[i].StartAnim) | ||
179 | { | ||
180 | ClientAvatar.current_anim = AgentAni.AnimationList[i].AnimID; | ||
181 | ClientAvatar.anim_seq = 1; | ||
182 | ClientAvatar.SendAnimPack(); | ||
183 | } | ||
184 | } | ||
185 | } | ||
186 | break; | ||
187 | case PacketType.ObjectSelect: | ||
188 | ObjectSelectPacket incomingselect = (ObjectSelectPacket)Pack; | ||
189 | for (int i = 0; i < incomingselect.ObjectData.Length; i++) | ||
190 | { | ||
191 | foreach (Entity ent in m_world.Entities.Values) | ||
192 | { | ||
193 | if (ent.localid == incomingselect.ObjectData[i].ObjectLocalID) | ||
194 | { | ||
195 | ((OpenSim.world.Primitive)ent).GetProperites(this); | ||
196 | break; | ||
197 | } | ||
198 | } | ||
199 | } | ||
200 | break; | ||
201 | case PacketType.ViewerEffect: | ||
202 | ViewerEffectPacket viewer = (ViewerEffectPacket)Pack; | ||
203 | foreach (ClientView client in m_clientThreads.Values) | ||
204 | { | ||
205 | if (client.AgentID != this.AgentID) | ||
206 | { | ||
207 | viewer.AgentData.AgentID = client.AgentID; | ||
208 | viewer.AgentData.SessionID = client.SessionID; | ||
209 | client.OutPacket(viewer); | ||
210 | } | ||
211 | } | ||
212 | break; | ||
213 | #endregion | ||
214 | |||
215 | #region Inventory/Asset/Other related packets | ||
216 | case PacketType.RequestImage: | ||
217 | RequestImagePacket imageRequest = (RequestImagePacket)Pack; | ||
218 | for (int i = 0; i < imageRequest.RequestImage.Length; i++) | ||
219 | { | ||
220 | m_assetCache.AddTextureRequest(this, imageRequest.RequestImage[i].Image); | ||
221 | } | ||
222 | break; | ||
223 | case PacketType.TransferRequest: | ||
224 | //Console.WriteLine("OpenSimClient.cs:ProcessInPacket() - Got transfer request"); | ||
225 | TransferRequestPacket transfer = (TransferRequestPacket)Pack; | ||
226 | m_assetCache.AddAssetRequest(this, transfer); | ||
227 | break; | ||
161 | case PacketType.AssetUploadRequest: | 228 | case PacketType.AssetUploadRequest: |
162 | AssetUploadRequestPacket request = (AssetUploadRequestPacket)Pack; | 229 | AssetUploadRequestPacket request = (AssetUploadRequestPacket)Pack; |
163 | this.UploadAssets.HandleUploadPacket(request, request.AssetBlock.TransactionID.Combine(this.SecureSessionID)); | 230 | this.UploadAssets.HandleUploadPacket(request, request.AssetBlock.TransactionID.Combine(this.SecureSessionID)); |
@@ -228,18 +295,6 @@ namespace OpenSim | |||
228 | } | 295 | } |
229 | } | 296 | } |
230 | break; | 297 | break; |
231 | case PacketType.ViewerEffect: | ||
232 | ViewerEffectPacket viewer = (ViewerEffectPacket)Pack; | ||
233 | foreach (SimClient client in m_clientThreads.Values) | ||
234 | { | ||
235 | if (client.AgentID != this.AgentID) | ||
236 | { | ||
237 | viewer.AgentData.AgentID = client.AgentID; | ||
238 | viewer.AgentData.SessionID = client.SessionID; | ||
239 | client.OutPacket(viewer); | ||
240 | } | ||
241 | } | ||
242 | break; | ||
243 | case PacketType.RequestTaskInventory: | 298 | case PacketType.RequestTaskInventory: |
244 | // Console.WriteLine(Pack.ToString()); | 299 | // Console.WriteLine(Pack.ToString()); |
245 | RequestTaskInventoryPacket requesttask = (RequestTaskInventoryPacket)Pack; | 300 | RequestTaskInventoryPacket requesttask = (RequestTaskInventoryPacket)Pack; |
@@ -292,35 +347,6 @@ namespace OpenSim | |||
292 | } | 347 | } |
293 | } | 348 | } |
294 | break; | 349 | break; |
295 | case PacketType.AgentAnimation: | ||
296 | if (!m_child) | ||
297 | { | ||
298 | AgentAnimationPacket AgentAni = (AgentAnimationPacket)Pack; | ||
299 | for (int i = 0; i < AgentAni.AnimationList.Length; i++) | ||
300 | { | ||
301 | if (AgentAni.AnimationList[i].StartAnim) | ||
302 | { | ||
303 | ClientAvatar.current_anim = AgentAni.AnimationList[i].AnimID; | ||
304 | ClientAvatar.anim_seq = 1; | ||
305 | ClientAvatar.SendAnimPack(); | ||
306 | } | ||
307 | } | ||
308 | } | ||
309 | break; | ||
310 | case PacketType.ObjectSelect: | ||
311 | ObjectSelectPacket incomingselect = (ObjectSelectPacket)Pack; | ||
312 | for (int i = 0; i < incomingselect.ObjectData.Length; i++) | ||
313 | { | ||
314 | foreach (Entity ent in m_world.Entities.Values) | ||
315 | { | ||
316 | if (ent.localid == incomingselect.ObjectData[i].ObjectLocalID) | ||
317 | { | ||
318 | ((OpenSim.world.Primitive)ent).GetProperites(this); | ||
319 | break; | ||
320 | } | ||
321 | } | ||
322 | } | ||
323 | break; | ||
324 | case PacketType.MapLayerRequest: | 350 | case PacketType.MapLayerRequest: |
325 | this.RequestMapLayer(); | 351 | this.RequestMapLayer(); |
326 | break; | 352 | break; |
@@ -329,7 +355,6 @@ namespace OpenSim | |||
329 | 355 | ||
330 | this.RequestMapBlocks(MapRequest.PositionData.MinX, MapRequest.PositionData.MinY, MapRequest.PositionData.MaxX, MapRequest.PositionData.MaxY); | 356 | this.RequestMapBlocks(MapRequest.PositionData.MinX, MapRequest.PositionData.MinY, MapRequest.PositionData.MaxX, MapRequest.PositionData.MaxY); |
331 | break; | 357 | break; |
332 | |||
333 | case PacketType.TeleportLandmarkRequest: | 358 | case PacketType.TeleportLandmarkRequest: |
334 | TeleportLandmarkRequestPacket tpReq = (TeleportLandmarkRequestPacket)Pack; | 359 | TeleportLandmarkRequestPacket tpReq = (TeleportLandmarkRequestPacket)Pack; |
335 | 360 | ||
@@ -378,7 +403,6 @@ namespace OpenSim | |||
378 | OutPacket(tpCancel); | 403 | OutPacket(tpCancel); |
379 | } | 404 | } |
380 | break; | 405 | break; |
381 | |||
382 | case PacketType.TeleportLocationRequest: | 406 | case PacketType.TeleportLocationRequest: |
383 | TeleportLocationRequestPacket tpLocReq = (TeleportLocationRequestPacket)Pack; | 407 | TeleportLocationRequestPacket tpLocReq = (TeleportLocationRequestPacket)Pack; |
384 | Console.WriteLine(tpLocReq.ToString()); | 408 | Console.WriteLine(tpLocReq.ToString()); |
@@ -410,8 +434,8 @@ namespace OpenSim | |||
410 | OutPacket(tpLocal); | 434 | OutPacket(tpLocal); |
411 | 435 | ||
412 | } | 436 | } |
413 | |||
414 | break; | 437 | break; |
438 | #endregion | ||
415 | } | 439 | } |
416 | } | 440 | } |
417 | } | 441 | } |
diff --git a/OpenSim.RegionServer/SimClient.cs b/OpenSim.RegionServer/ClientView.cs index 3b243cf..a97049d 100644 --- a/OpenSim.RegionServer/SimClient.cs +++ b/OpenSim.RegionServer/ClientView.cs | |||
@@ -44,43 +44,31 @@ using OpenSim.Assets; | |||
44 | 44 | ||
45 | namespace OpenSim | 45 | namespace OpenSim |
46 | { | 46 | { |
47 | public delegate bool PacketMethod(SimClient simClient, Packet packet); | 47 | public delegate bool PacketMethod(ClientView simClient, Packet packet); |
48 | 48 | ||
49 | /// <summary> | 49 | /// <summary> |
50 | /// Handles new client connections | 50 | /// Handles new client connections |
51 | /// Constructor takes a single Packet and authenticates everything | 51 | /// Constructor takes a single Packet and authenticates everything |
52 | /// </summary> | 52 | /// </summary> |
53 | public partial class SimClient | 53 | public partial class ClientView : ClientViewBase |
54 | { | 54 | { |
55 | public LLUUID AgentID; | 55 | public LLUUID AgentID; |
56 | public LLUUID SessionID; | 56 | public LLUUID SessionID; |
57 | public LLUUID SecureSessionID = LLUUID.Zero; | 57 | public LLUUID SecureSessionID = LLUUID.Zero; |
58 | public bool m_child; | 58 | public bool m_child; |
59 | public uint CircuitCode; | ||
60 | public world.Avatar ClientAvatar; | 59 | public world.Avatar ClientAvatar; |
61 | private UseCircuitCodePacket cirpack; | 60 | private UseCircuitCodePacket cirpack; |
62 | public Thread ClientThread; | 61 | public Thread ClientThread; |
63 | public EndPoint userEP; | ||
64 | public LLVector3 startpos; | 62 | public LLVector3 startpos; |
65 | private BlockingQueue<QueItem> PacketQueue; | 63 | |
66 | private Dictionary<uint, uint> PendingAcks = new Dictionary<uint, uint>(); | ||
67 | private Dictionary<uint, Packet> NeedAck = new Dictionary<uint, Packet>(); | ||
68 | //private Dictionary<LLUUID, AssetBase> UploadedAssets = new Dictionary<LLUUID, AssetBase>(); | ||
69 | private System.Timers.Timer AckTimer; | ||
70 | private uint Sequence = 0; | ||
71 | private object SequenceLock = new object(); | ||
72 | private const int MAX_APPENDED_ACKS = 10; | ||
73 | private const int RESEND_TIMEOUT = 4000; | ||
74 | private const int MAX_SEQUENCE = 0xFFFFFF; | ||
75 | private AgentAssetUpload UploadAssets; | 64 | private AgentAssetUpload UploadAssets; |
76 | private LLUUID newAssetFolder = LLUUID.Zero; | 65 | private LLUUID newAssetFolder = LLUUID.Zero; |
77 | private bool debug = false; | 66 | private bool debug = false; |
78 | private World m_world; | 67 | private World m_world; |
79 | private Dictionary<uint, SimClient> m_clientThreads; | 68 | private Dictionary<uint, ClientView> m_clientThreads; |
80 | private AssetCache m_assetCache; | 69 | private AssetCache m_assetCache; |
81 | private IGridServer m_gridServer; | 70 | private IGridServer m_gridServer; |
82 | private IUserServer m_userServer = null; | 71 | private IUserServer m_userServer = null; |
83 | private OpenSimNetworkHandler m_networkServer; | ||
84 | private InventoryCache m_inventoryCache; | 72 | private InventoryCache m_inventoryCache; |
85 | public bool m_sandboxMode; | 73 | public bool m_sandboxMode; |
86 | private int cachedtextureserial = 0; | 74 | private int cachedtextureserial = 0; |
@@ -99,7 +87,7 @@ namespace OpenSim | |||
99 | } | 87 | } |
100 | } | 88 | } |
101 | 89 | ||
102 | public SimClient(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, World world, Dictionary<uint, SimClient> clientThreads, AssetCache assetCache, IGridServer gridServer, OpenSimNetworkHandler application, InventoryCache inventoryCache, bool sandboxMode, bool child, RegionInfo regionDat, AuthenticateSessionsBase authenSessions) | 90 | public ClientView(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, World world, Dictionary<uint, ClientView> clientThreads, AssetCache assetCache, IGridServer gridServer, OpenSimNetworkHandler application, InventoryCache inventoryCache, bool sandboxMode, bool child, RegionInfo regionDat, AuthenticateSessionsBase authenSessions) |
103 | { | 91 | { |
104 | m_world = world; | 92 | m_world = world; |
105 | m_clientThreads = clientThreads; | 93 | m_clientThreads = clientThreads; |
@@ -170,7 +158,7 @@ namespace OpenSim | |||
170 | kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1]; | 158 | kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1]; |
171 | kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock(); | 159 | kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock(); |
172 | kill.ObjectData[0].ID = this.ClientAvatar.localid; | 160 | kill.ObjectData[0].ID = this.ClientAvatar.localid; |
173 | foreach (SimClient client in m_clientThreads.Values) | 161 | foreach (ClientView client in m_clientThreads.Values) |
174 | { | 162 | { |
175 | client.OutPacket(kill); | 163 | client.OutPacket(kill); |
176 | } | 164 | } |
@@ -247,246 +235,6 @@ namespace OpenSim | |||
247 | 235 | ||
248 | # endregion | 236 | # endregion |
249 | 237 | ||
250 | # region Low Level Packet Methods | ||
251 | |||
252 | private void ack_pack(Packet Pack) | ||
253 | { | ||
254 | if (Pack.Header.Reliable) | ||
255 | { | ||
256 | libsecondlife.Packets.PacketAckPacket ack_it = new PacketAckPacket(); | ||
257 | ack_it.Packets = new PacketAckPacket.PacketsBlock[1]; | ||
258 | ack_it.Packets[0] = new PacketAckPacket.PacketsBlock(); | ||
259 | ack_it.Packets[0].ID = Pack.Header.Sequence; | ||
260 | ack_it.Header.Reliable = false; | ||
261 | |||
262 | OutPacket(ack_it); | ||
263 | |||
264 | } | ||
265 | /* | ||
266 | if (Pack.Header.Reliable) | ||
267 | { | ||
268 | lock (PendingAcks) | ||
269 | { | ||
270 | uint sequence = (uint)Pack.Header.Sequence; | ||
271 | if (!PendingAcks.ContainsKey(sequence)) { PendingAcks[sequence] = sequence; } | ||
272 | } | ||
273 | }*/ | ||
274 | } | ||
275 | |||
276 | private void ResendUnacked() | ||
277 | { | ||
278 | int now = Environment.TickCount; | ||
279 | |||
280 | lock (NeedAck) | ||
281 | { | ||
282 | foreach (Packet packet in NeedAck.Values) | ||
283 | { | ||
284 | if ((now - packet.TickCount > RESEND_TIMEOUT) && (!packet.Header.Resent)) | ||
285 | { | ||
286 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.VERBOSE, "Resending " + packet.Type.ToString() + " packet, " + | ||
287 | (now - packet.TickCount) + "ms have passed"); | ||
288 | |||
289 | packet.Header.Resent = true; | ||
290 | OutPacket(packet); | ||
291 | } | ||
292 | } | ||
293 | } | ||
294 | } | ||
295 | |||
296 | private void SendAcks() | ||
297 | { | ||
298 | lock (PendingAcks) | ||
299 | { | ||
300 | if (PendingAcks.Count > 0) | ||
301 | { | ||
302 | if (PendingAcks.Count > 250) | ||
303 | { | ||
304 | // FIXME: Handle the odd case where we have too many pending ACKs queued up | ||
305 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.VERBOSE, "Too many ACKs queued up!"); | ||
306 | return; | ||
307 | } | ||
308 | |||
309 | //OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Sending PacketAck"); | ||
310 | |||
311 | |||
312 | int i = 0; | ||
313 | PacketAckPacket acks = new PacketAckPacket(); | ||
314 | acks.Packets = new PacketAckPacket.PacketsBlock[PendingAcks.Count]; | ||
315 | |||
316 | foreach (uint ack in PendingAcks.Values) | ||
317 | { | ||
318 | acks.Packets[i] = new PacketAckPacket.PacketsBlock(); | ||
319 | acks.Packets[i].ID = ack; | ||
320 | i++; | ||
321 | } | ||
322 | |||
323 | acks.Header.Reliable = false; | ||
324 | OutPacket(acks); | ||
325 | |||
326 | PendingAcks.Clear(); | ||
327 | } | ||
328 | } | ||
329 | } | ||
330 | |||
331 | private void AckTimer_Elapsed(object sender, ElapsedEventArgs ea) | ||
332 | { | ||
333 | SendAcks(); | ||
334 | ResendUnacked(); | ||
335 | } | ||
336 | |||
337 | # endregion | ||
338 | |||
339 | #region Packet Queue Processing | ||
340 | |||
341 | protected virtual void ProcessOutPacket(Packet Pack) | ||
342 | { | ||
343 | // Keep track of when this packet was sent out | ||
344 | Pack.TickCount = Environment.TickCount; | ||
345 | |||
346 | if (!Pack.Header.Resent) | ||
347 | { | ||
348 | // Set the sequence number | ||
349 | lock (SequenceLock) | ||
350 | { | ||
351 | if (Sequence >= MAX_SEQUENCE) | ||
352 | Sequence = 1; | ||
353 | else | ||
354 | Sequence++; | ||
355 | Pack.Header.Sequence = Sequence; | ||
356 | } | ||
357 | |||
358 | if (Pack.Header.Reliable) //DIRTY HACK | ||
359 | { | ||
360 | lock (NeedAck) | ||
361 | { | ||
362 | if (!NeedAck.ContainsKey(Pack.Header.Sequence)) | ||
363 | { | ||
364 | try | ||
365 | { | ||
366 | NeedAck.Add(Pack.Header.Sequence, Pack); | ||
367 | } | ||
368 | catch (Exception e) // HACKY | ||
369 | { | ||
370 | e.ToString(); | ||
371 | // Ignore | ||
372 | // Seems to throw a exception here occasionally | ||
373 | // of 'duplicate key' despite being locked. | ||
374 | // !?!?!? | ||
375 | } | ||
376 | } | ||
377 | else | ||
378 | { | ||
379 | // Client.Log("Attempted to add a duplicate sequence number (" + | ||
380 | // packet.Header.Sequence + ") to the NeedAck dictionary for packet type " + | ||
381 | // packet.Type.ToString(), Helpers.LogLevel.Warning); | ||
382 | } | ||
383 | } | ||
384 | |||
385 | // Don't append ACKs to resent packets, in case that's what was causing the | ||
386 | // delivery to fail | ||
387 | if (!Pack.Header.Resent) | ||
388 | { | ||
389 | // Append any ACKs that need to be sent out to this packet | ||
390 | lock (PendingAcks) | ||
391 | { | ||
392 | if (PendingAcks.Count > 0 && PendingAcks.Count < MAX_APPENDED_ACKS && | ||
393 | Pack.Type != PacketType.PacketAck && | ||
394 | Pack.Type != PacketType.LogoutRequest) | ||
395 | { | ||
396 | Pack.Header.AckList = new uint[PendingAcks.Count]; | ||
397 | int i = 0; | ||
398 | |||
399 | foreach (uint ack in PendingAcks.Values) | ||
400 | { | ||
401 | Pack.Header.AckList[i] = ack; | ||
402 | i++; | ||
403 | } | ||
404 | |||
405 | PendingAcks.Clear(); | ||
406 | Pack.Header.AppendedAcks = true; | ||
407 | } | ||
408 | } | ||
409 | } | ||
410 | } | ||
411 | } | ||
412 | |||
413 | byte[] ZeroOutBuffer = new byte[4096]; | ||
414 | byte[] sendbuffer; | ||
415 | sendbuffer = Pack.ToBytes(); | ||
416 | |||
417 | try | ||
418 | { | ||
419 | if (Pack.Header.Zerocoded) | ||
420 | { | ||
421 | int packetsize = Helpers.ZeroEncode(sendbuffer, sendbuffer.Length, ZeroOutBuffer); | ||
422 | m_networkServer.SendPacketTo(ZeroOutBuffer, packetsize, SocketFlags.None, CircuitCode);//userEP); | ||
423 | } | ||
424 | else | ||
425 | { | ||
426 | m_networkServer.SendPacketTo(sendbuffer, sendbuffer.Length, SocketFlags.None, CircuitCode); //userEP); | ||
427 | } | ||
428 | } | ||
429 | catch (Exception) | ||
430 | { | ||
431 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "OpenSimClient.cs:ProcessOutPacket() - WARNING: Socket exception occurred on connection " + userEP.ToString() + " - killing thread"); | ||
432 | ClientThread.Abort(); | ||
433 | } | ||
434 | |||
435 | } | ||
436 | |||
437 | public virtual void InPacket(Packet NewPack) | ||
438 | { | ||
439 | // Handle appended ACKs | ||
440 | if (NewPack.Header.AppendedAcks) | ||
441 | { | ||
442 | lock (NeedAck) | ||
443 | { | ||
444 | foreach (uint ack in NewPack.Header.AckList) | ||
445 | { | ||
446 | NeedAck.Remove(ack); | ||
447 | } | ||
448 | } | ||
449 | } | ||
450 | |||
451 | // Handle PacketAck packets | ||
452 | if (NewPack.Type == PacketType.PacketAck) | ||
453 | { | ||
454 | PacketAckPacket ackPacket = (PacketAckPacket)NewPack; | ||
455 | |||
456 | lock (NeedAck) | ||
457 | { | ||
458 | foreach (PacketAckPacket.PacketsBlock block in ackPacket.Packets) | ||
459 | { | ||
460 | NeedAck.Remove(block.ID); | ||
461 | } | ||
462 | } | ||
463 | } | ||
464 | else if ((NewPack.Type == PacketType.StartPingCheck)) | ||
465 | { | ||
466 | //reply to pingcheck | ||
467 | libsecondlife.Packets.StartPingCheckPacket startPing = (libsecondlife.Packets.StartPingCheckPacket)NewPack; | ||
468 | libsecondlife.Packets.CompletePingCheckPacket endPing = new CompletePingCheckPacket(); | ||
469 | endPing.PingID.PingID = startPing.PingID.PingID; | ||
470 | OutPacket(endPing); | ||
471 | } | ||
472 | else | ||
473 | { | ||
474 | QueItem item = new QueItem(); | ||
475 | item.Packet = NewPack; | ||
476 | item.Incoming = true; | ||
477 | this.PacketQueue.Enqueue(item); | ||
478 | } | ||
479 | |||
480 | } | ||
481 | |||
482 | public virtual void OutPacket(Packet NewPack) | ||
483 | { | ||
484 | QueItem item = new QueItem(); | ||
485 | item.Packet = NewPack; | ||
486 | item.Incoming = false; | ||
487 | this.PacketQueue.Enqueue(item); | ||
488 | } | ||
489 | |||
490 | protected virtual void ClientLoop() | 238 | protected virtual void ClientLoop() |
491 | { | 239 | { |
492 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "OpenSimClient.cs:ClientLoop() - Entered loop"); | 240 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "OpenSimClient.cs:ClientLoop() - Entered loop"); |
@@ -506,8 +254,6 @@ namespace OpenSim | |||
506 | } | 254 | } |
507 | } | 255 | } |
508 | 256 | ||
509 | #endregion | ||
510 | |||
511 | # region Setup | 257 | # region Setup |
512 | 258 | ||
513 | protected virtual void InitNewClient() | 259 | protected virtual void InitNewClient() |
@@ -556,6 +302,31 @@ namespace OpenSim | |||
556 | } | 302 | } |
557 | # endregion | 303 | # endregion |
558 | 304 | ||
305 | |||
306 | protected override void KillThread() | ||
307 | { | ||
308 | this.ClientThread.Abort(); | ||
309 | } | ||
310 | |||
311 | #region World/Avatar To Viewer Methods | ||
312 | |||
313 | public void SendChatMessage(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID) | ||
314 | { | ||
315 | System.Text.Encoding enc = System.Text.Encoding.ASCII; | ||
316 | libsecondlife.Packets.ChatFromSimulatorPacket reply = new ChatFromSimulatorPacket(); | ||
317 | reply.ChatData.Audible = 1; | ||
318 | reply.ChatData.Message = message; | ||
319 | reply.ChatData.ChatType = type; | ||
320 | reply.ChatData.SourceType = 1; | ||
321 | reply.ChatData.Position = fromPos; | ||
322 | reply.ChatData.FromName = enc.GetBytes(fromName + "\0"); | ||
323 | reply.ChatData.OwnerID = fromAgentID; | ||
324 | reply.ChatData.SourceID = fromAgentID; | ||
325 | |||
326 | this.OutPacket(reply); | ||
327 | } | ||
328 | #endregion | ||
329 | |||
559 | #region Inventory Creation | 330 | #region Inventory Creation |
560 | private void SetupInventory(AuthenticateResponse sessionInfo) | 331 | private void SetupInventory(AuthenticateResponse sessionInfo) |
561 | { | 332 | { |
@@ -646,17 +417,5 @@ namespace OpenSim | |||
646 | } | 417 | } |
647 | #endregion | 418 | #endregion |
648 | 419 | ||
649 | #region Nested Classes | ||
650 | |||
651 | public class QueItem | ||
652 | { | ||
653 | public QueItem() | ||
654 | { | ||
655 | } | ||
656 | |||
657 | public Packet Packet; | ||
658 | public bool Incoming; | ||
659 | } | ||
660 | #endregion | ||
661 | } | 420 | } |
662 | } | 421 | } |
diff --git a/OpenSim.RegionServer/ClientViewBase.cs b/OpenSim.RegionServer/ClientViewBase.cs new file mode 100644 index 0000000..814b025 --- /dev/null +++ b/OpenSim.RegionServer/ClientViewBase.cs | |||
@@ -0,0 +1,299 @@ | |||
1 | using System; | ||
2 | using System.Collections; | ||
3 | using System.Collections.Generic; | ||
4 | using libsecondlife; | ||
5 | using libsecondlife.Packets; | ||
6 | using System.Net; | ||
7 | using System.Net.Sockets; | ||
8 | using System.IO; | ||
9 | using System.Threading; | ||
10 | using System.Timers; | ||
11 | using OpenSim.Framework.Utilities; | ||
12 | |||
13 | |||
14 | namespace OpenSim | ||
15 | { | ||
16 | public class ClientViewBase | ||
17 | { | ||
18 | protected BlockingQueue<QueItem> PacketQueue; | ||
19 | protected Dictionary<uint, uint> PendingAcks = new Dictionary<uint, uint>(); | ||
20 | protected Dictionary<uint, Packet> NeedAck = new Dictionary<uint, Packet>(); | ||
21 | |||
22 | protected System.Timers.Timer AckTimer; | ||
23 | protected uint Sequence = 0; | ||
24 | protected object SequenceLock = new object(); | ||
25 | protected const int MAX_APPENDED_ACKS = 10; | ||
26 | protected const int RESEND_TIMEOUT = 4000; | ||
27 | protected const int MAX_SEQUENCE = 0xFFFFFF; | ||
28 | |||
29 | public uint CircuitCode; | ||
30 | public EndPoint userEP; | ||
31 | |||
32 | protected OpenSimNetworkHandler m_networkServer; | ||
33 | |||
34 | public ClientViewBase() | ||
35 | { | ||
36 | |||
37 | } | ||
38 | |||
39 | protected virtual void ProcessInPacket(Packet Pack) | ||
40 | { | ||
41 | |||
42 | } | ||
43 | |||
44 | protected virtual void ProcessOutPacket(Packet Pack) | ||
45 | { | ||
46 | // Keep track of when this packet was sent out | ||
47 | Pack.TickCount = Environment.TickCount; | ||
48 | |||
49 | if (!Pack.Header.Resent) | ||
50 | { | ||
51 | // Set the sequence number | ||
52 | lock (SequenceLock) | ||
53 | { | ||
54 | if (Sequence >= MAX_SEQUENCE) | ||
55 | Sequence = 1; | ||
56 | else | ||
57 | Sequence++; | ||
58 | Pack.Header.Sequence = Sequence; | ||
59 | } | ||
60 | |||
61 | if (Pack.Header.Reliable) //DIRTY HACK | ||
62 | { | ||
63 | lock (NeedAck) | ||
64 | { | ||
65 | if (!NeedAck.ContainsKey(Pack.Header.Sequence)) | ||
66 | { | ||
67 | try | ||
68 | { | ||
69 | NeedAck.Add(Pack.Header.Sequence, Pack); | ||
70 | } | ||
71 | catch (Exception e) // HACKY | ||
72 | { | ||
73 | e.ToString(); | ||
74 | // Ignore | ||
75 | // Seems to throw a exception here occasionally | ||
76 | // of 'duplicate key' despite being locked. | ||
77 | // !?!?!? | ||
78 | } | ||
79 | } | ||
80 | else | ||
81 | { | ||
82 | // Client.Log("Attempted to add a duplicate sequence number (" + | ||
83 | // packet.Header.Sequence + ") to the NeedAck dictionary for packet type " + | ||
84 | // packet.Type.ToString(), Helpers.LogLevel.Warning); | ||
85 | } | ||
86 | } | ||
87 | |||
88 | // Don't append ACKs to resent packets, in case that's what was causing the | ||
89 | // delivery to fail | ||
90 | if (!Pack.Header.Resent) | ||
91 | { | ||
92 | // Append any ACKs that need to be sent out to this packet | ||
93 | lock (PendingAcks) | ||
94 | { | ||
95 | if (PendingAcks.Count > 0 && PendingAcks.Count < MAX_APPENDED_ACKS && | ||
96 | Pack.Type != PacketType.PacketAck && | ||
97 | Pack.Type != PacketType.LogoutRequest) | ||
98 | { | ||
99 | Pack.Header.AckList = new uint[PendingAcks.Count]; | ||
100 | int i = 0; | ||
101 | |||
102 | foreach (uint ack in PendingAcks.Values) | ||
103 | { | ||
104 | Pack.Header.AckList[i] = ack; | ||
105 | i++; | ||
106 | } | ||
107 | |||
108 | PendingAcks.Clear(); | ||
109 | Pack.Header.AppendedAcks = true; | ||
110 | } | ||
111 | } | ||
112 | } | ||
113 | } | ||
114 | } | ||
115 | |||
116 | byte[] ZeroOutBuffer = new byte[4096]; | ||
117 | byte[] sendbuffer; | ||
118 | sendbuffer = Pack.ToBytes(); | ||
119 | |||
120 | try | ||
121 | { | ||
122 | if (Pack.Header.Zerocoded) | ||
123 | { | ||
124 | int packetsize = Helpers.ZeroEncode(sendbuffer, sendbuffer.Length, ZeroOutBuffer); | ||
125 | m_networkServer.SendPacketTo(ZeroOutBuffer, packetsize, SocketFlags.None, CircuitCode);//userEP); | ||
126 | } | ||
127 | else | ||
128 | { | ||
129 | m_networkServer.SendPacketTo(sendbuffer, sendbuffer.Length, SocketFlags.None, CircuitCode); //userEP); | ||
130 | } | ||
131 | } | ||
132 | catch (Exception) | ||
133 | { | ||
134 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM, "OpenSimClient.cs:ProcessOutPacket() - WARNING: Socket exception occurred on connection " + userEP.ToString() + " - killing thread"); | ||
135 | this.KillThread(); | ||
136 | } | ||
137 | |||
138 | } | ||
139 | |||
140 | public virtual void InPacket(Packet NewPack) | ||
141 | { | ||
142 | // Handle appended ACKs | ||
143 | if (NewPack.Header.AppendedAcks) | ||
144 | { | ||
145 | lock (NeedAck) | ||
146 | { | ||
147 | foreach (uint ack in NewPack.Header.AckList) | ||
148 | { | ||
149 | NeedAck.Remove(ack); | ||
150 | } | ||
151 | } | ||
152 | } | ||
153 | |||
154 | // Handle PacketAck packets | ||
155 | if (NewPack.Type == PacketType.PacketAck) | ||
156 | { | ||
157 | PacketAckPacket ackPacket = (PacketAckPacket)NewPack; | ||
158 | |||
159 | lock (NeedAck) | ||
160 | { | ||
161 | foreach (PacketAckPacket.PacketsBlock block in ackPacket.Packets) | ||
162 | { | ||
163 | NeedAck.Remove(block.ID); | ||
164 | } | ||
165 | } | ||
166 | } | ||
167 | else if ((NewPack.Type == PacketType.StartPingCheck)) | ||
168 | { | ||
169 | //reply to pingcheck | ||
170 | libsecondlife.Packets.StartPingCheckPacket startPing = (libsecondlife.Packets.StartPingCheckPacket)NewPack; | ||
171 | libsecondlife.Packets.CompletePingCheckPacket endPing = new CompletePingCheckPacket(); | ||
172 | endPing.PingID.PingID = startPing.PingID.PingID; | ||
173 | OutPacket(endPing); | ||
174 | } | ||
175 | else | ||
176 | { | ||
177 | QueItem item = new QueItem(); | ||
178 | item.Packet = NewPack; | ||
179 | item.Incoming = true; | ||
180 | this.PacketQueue.Enqueue(item); | ||
181 | } | ||
182 | |||
183 | } | ||
184 | |||
185 | public virtual void OutPacket(Packet NewPack) | ||
186 | { | ||
187 | QueItem item = new QueItem(); | ||
188 | item.Packet = NewPack; | ||
189 | item.Incoming = false; | ||
190 | this.PacketQueue.Enqueue(item); | ||
191 | } | ||
192 | |||
193 | # region Low Level Packet Methods | ||
194 | |||
195 | protected void ack_pack(Packet Pack) | ||
196 | { | ||
197 | if (Pack.Header.Reliable) | ||
198 | { | ||
199 | libsecondlife.Packets.PacketAckPacket ack_it = new PacketAckPacket(); | ||
200 | ack_it.Packets = new PacketAckPacket.PacketsBlock[1]; | ||
201 | ack_it.Packets[0] = new PacketAckPacket.PacketsBlock(); | ||
202 | ack_it.Packets[0].ID = Pack.Header.Sequence; | ||
203 | ack_it.Header.Reliable = false; | ||
204 | |||
205 | OutPacket(ack_it); | ||
206 | |||
207 | } | ||
208 | /* | ||
209 | if (Pack.Header.Reliable) | ||
210 | { | ||
211 | lock (PendingAcks) | ||
212 | { | ||
213 | uint sequence = (uint)Pack.Header.Sequence; | ||
214 | if (!PendingAcks.ContainsKey(sequence)) { PendingAcks[sequence] = sequence; } | ||
215 | } | ||
216 | }*/ | ||
217 | } | ||
218 | |||
219 | protected void ResendUnacked() | ||
220 | { | ||
221 | int now = Environment.TickCount; | ||
222 | |||
223 | lock (NeedAck) | ||
224 | { | ||
225 | foreach (Packet packet in NeedAck.Values) | ||
226 | { | ||
227 | if ((now - packet.TickCount > RESEND_TIMEOUT) && (!packet.Header.Resent)) | ||
228 | { | ||
229 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.VERBOSE, "Resending " + packet.Type.ToString() + " packet, " + | ||
230 | (now - packet.TickCount) + "ms have passed"); | ||
231 | |||
232 | packet.Header.Resent = true; | ||
233 | OutPacket(packet); | ||
234 | } | ||
235 | } | ||
236 | } | ||
237 | } | ||
238 | |||
239 | protected void SendAcks() | ||
240 | { | ||
241 | lock (PendingAcks) | ||
242 | { | ||
243 | if (PendingAcks.Count > 0) | ||
244 | { | ||
245 | if (PendingAcks.Count > 250) | ||
246 | { | ||
247 | // FIXME: Handle the odd case where we have too many pending ACKs queued up | ||
248 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.VERBOSE, "Too many ACKs queued up!"); | ||
249 | return; | ||
250 | } | ||
251 | |||
252 | //OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Sending PacketAck"); | ||
253 | |||
254 | |||
255 | int i = 0; | ||
256 | PacketAckPacket acks = new PacketAckPacket(); | ||
257 | acks.Packets = new PacketAckPacket.PacketsBlock[PendingAcks.Count]; | ||
258 | |||
259 | foreach (uint ack in PendingAcks.Values) | ||
260 | { | ||
261 | acks.Packets[i] = new PacketAckPacket.PacketsBlock(); | ||
262 | acks.Packets[i].ID = ack; | ||
263 | i++; | ||
264 | } | ||
265 | |||
266 | acks.Header.Reliable = false; | ||
267 | OutPacket(acks); | ||
268 | |||
269 | PendingAcks.Clear(); | ||
270 | } | ||
271 | } | ||
272 | } | ||
273 | |||
274 | protected void AckTimer_Elapsed(object sender, ElapsedEventArgs ea) | ||
275 | { | ||
276 | SendAcks(); | ||
277 | ResendUnacked(); | ||
278 | } | ||
279 | #endregion | ||
280 | |||
281 | protected virtual void KillThread() | ||
282 | { | ||
283 | |||
284 | } | ||
285 | |||
286 | #region Nested Classes | ||
287 | |||
288 | public class QueItem | ||
289 | { | ||
290 | public QueItem() | ||
291 | { | ||
292 | } | ||
293 | |||
294 | public Packet Packet; | ||
295 | public bool Incoming; | ||
296 | } | ||
297 | #endregion | ||
298 | } | ||
299 | } | ||
diff --git a/OpenSim.RegionServer/OpenSim.RegionServer.csproj b/OpenSim.RegionServer/OpenSim.RegionServer.csproj index 93285b4..512ee88 100644 --- a/OpenSim.RegionServer/OpenSim.RegionServer.csproj +++ b/OpenSim.RegionServer/OpenSim.RegionServer.csproj | |||
@@ -136,40 +136,40 @@ | |||
136 | <Compile Include="AuthenticateSessionsRemote.cs"> | 136 | <Compile Include="AuthenticateSessionsRemote.cs"> |
137 | <SubType>Code</SubType> | 137 | <SubType>Code</SubType> |
138 | </Compile> | 138 | </Compile> |
139 | <Compile Include="Grid.cs"> | 139 | <Compile Include="ClientView.cs"> |
140 | <SubType>Code</SubType> | 140 | <SubType>Code</SubType> |
141 | </Compile> | 141 | </Compile> |
142 | <Compile Include="OpenSimMain.cs"> | 142 | <Compile Include="ClientView.Grid.cs"> |
143 | <SubType>Code</SubType> | 143 | <SubType>Code</SubType> |
144 | </Compile> | 144 | </Compile> |
145 | <Compile Include="OpenSimNetworkHandler.cs"> | 145 | <Compile Include="ClientView.PacketHandlers.cs"> |
146 | <SubType>Code</SubType> | 146 | <SubType>Code</SubType> |
147 | </Compile> | 147 | </Compile> |
148 | <Compile Include="PacketServer.cs"> | 148 | <Compile Include="ClientView.ProcessPackets.cs"> |
149 | <SubType>Code</SubType> | 149 | <SubType>Code</SubType> |
150 | </Compile> | 150 | </Compile> |
151 | <Compile Include="RegionInfo.cs"> | 151 | <Compile Include="ClientViewBase.cs"> |
152 | <SubType>Code</SubType> | 152 | <SubType>Code</SubType> |
153 | </Compile> | 153 | </Compile> |
154 | <Compile Include="RegionInfoBase.cs"> | 154 | <Compile Include="Grid.cs"> |
155 | <SubType>Code</SubType> | 155 | <SubType>Code</SubType> |
156 | </Compile> | 156 | </Compile> |
157 | <Compile Include="RegionServerBase.cs"> | 157 | <Compile Include="OpenSimMain.cs"> |
158 | <SubType>Code</SubType> | 158 | <SubType>Code</SubType> |
159 | </Compile> | 159 | </Compile> |
160 | <Compile Include="SimClient.cs"> | 160 | <Compile Include="OpenSimNetworkHandler.cs"> |
161 | <SubType>Code</SubType> | 161 | <SubType>Code</SubType> |
162 | </Compile> | 162 | </Compile> |
163 | <Compile Include="SimClient.Grid.cs"> | 163 | <Compile Include="PacketServer.cs"> |
164 | <SubType>Code</SubType> | 164 | <SubType>Code</SubType> |
165 | </Compile> | 165 | </Compile> |
166 | <Compile Include="SimClient.PacketHandlers.cs"> | 166 | <Compile Include="RegionInfo.cs"> |
167 | <SubType>Code</SubType> | 167 | <SubType>Code</SubType> |
168 | </Compile> | 168 | </Compile> |
169 | <Compile Include="SimClient.ProcessPackets.cs"> | 169 | <Compile Include="RegionInfoBase.cs"> |
170 | <SubType>Code</SubType> | 170 | <SubType>Code</SubType> |
171 | </Compile> | 171 | </Compile> |
172 | <Compile Include="SimClientBase.cs"> | 172 | <Compile Include="RegionServerBase.cs"> |
173 | <SubType>Code</SubType> | 173 | <SubType>Code</SubType> |
174 | </Compile> | 174 | </Compile> |
175 | <Compile Include="UDPServer.cs"> | 175 | <Compile Include="UDPServer.cs"> |
diff --git a/OpenSim.RegionServer/OpenSim.RegionServer.dll.build b/OpenSim.RegionServer/OpenSim.RegionServer.dll.build index 35985ac..4ec3537 100644 --- a/OpenSim.RegionServer/OpenSim.RegionServer.dll.build +++ b/OpenSim.RegionServer/OpenSim.RegionServer.dll.build | |||
@@ -15,6 +15,11 @@ | |||
15 | <include name="AuthenticateSessionsBase.cs" /> | 15 | <include name="AuthenticateSessionsBase.cs" /> |
16 | <include name="AuthenticateSessionsLocal.cs" /> | 16 | <include name="AuthenticateSessionsLocal.cs" /> |
17 | <include name="AuthenticateSessionsRemote.cs" /> | 17 | <include name="AuthenticateSessionsRemote.cs" /> |
18 | <include name="ClientView.cs" /> | ||
19 | <include name="ClientView.Grid.cs" /> | ||
20 | <include name="ClientView.PacketHandlers.cs" /> | ||
21 | <include name="ClientView.ProcessPackets.cs" /> | ||
22 | <include name="ClientViewBase.cs" /> | ||
18 | <include name="Grid.cs" /> | 23 | <include name="Grid.cs" /> |
19 | <include name="OpenSimMain.cs" /> | 24 | <include name="OpenSimMain.cs" /> |
20 | <include name="OpenSimNetworkHandler.cs" /> | 25 | <include name="OpenSimNetworkHandler.cs" /> |
@@ -22,11 +27,6 @@ | |||
22 | <include name="RegionInfo.cs" /> | 27 | <include name="RegionInfo.cs" /> |
23 | <include name="RegionInfoBase.cs" /> | 28 | <include name="RegionInfoBase.cs" /> |
24 | <include name="RegionServerBase.cs" /> | 29 | <include name="RegionServerBase.cs" /> |
25 | <include name="SimClient.cs" /> | ||
26 | <include name="SimClient.Grid.cs" /> | ||
27 | <include name="SimClient.PacketHandlers.cs" /> | ||
28 | <include name="SimClient.ProcessPackets.cs" /> | ||
29 | <include name="SimClientBase.cs" /> | ||
30 | <include name="UDPServer.cs" /> | 30 | <include name="UDPServer.cs" /> |
31 | <include name="VersionInfo.cs" /> | 31 | <include name="VersionInfo.cs" /> |
32 | <include name="Assets/AssetCache.cs" /> | 32 | <include name="Assets/AssetCache.cs" /> |
diff --git a/OpenSim.RegionServer/PacketServer.cs b/OpenSim.RegionServer/PacketServer.cs index b60d10f..cb7de11 100644 --- a/OpenSim.RegionServer/PacketServer.cs +++ b/OpenSim.RegionServer/PacketServer.cs | |||
@@ -10,7 +10,7 @@ namespace OpenSim | |||
10 | { | 10 | { |
11 | private OpenSimNetworkHandler _networkHandler; | 11 | private OpenSimNetworkHandler _networkHandler; |
12 | private World _localWorld; | 12 | private World _localWorld; |
13 | public Dictionary<uint, SimClient> ClientThreads = new Dictionary<uint, SimClient>(); | 13 | public Dictionary<uint, ClientView> ClientThreads = new Dictionary<uint, ClientView>(); |
14 | 14 | ||
15 | public PacketServer(OpenSimNetworkHandler networkHandler) | 15 | public PacketServer(OpenSimNetworkHandler networkHandler) |
16 | { | 16 | { |
@@ -44,7 +44,7 @@ namespace OpenSim | |||
44 | 44 | ||
45 | } | 45 | } |
46 | 46 | ||
47 | public virtual void SendPacketToAllExcept(Packet packet, SimClient simClient) | 47 | public virtual void SendPacketToAllExcept(Packet packet, ClientView simClient) |
48 | { | 48 | { |
49 | 49 | ||
50 | } | 50 | } |
@@ -58,17 +58,16 @@ namespace OpenSim | |||
58 | { | 58 | { |
59 | if (this._localWorld != null) | 59 | if (this._localWorld != null) |
60 | { | 60 | { |
61 | SimClient.AddPacketHandler(PacketType.ModifyLand, _localWorld.ModifyTerrain); | 61 | ClientView.AddPacketHandler(PacketType.ModifyLand, _localWorld.ModifyTerrain); |
62 | SimClient.AddPacketHandler(PacketType.ChatFromViewer, _localWorld.SimChat); | 62 | ClientView.AddPacketHandler(PacketType.RezObject, _localWorld.RezObject); |
63 | SimClient.AddPacketHandler(PacketType.RezObject, _localWorld.RezObject); | 63 | ClientView.AddPacketHandler(PacketType.DeRezObject, _localWorld.DeRezObject); |
64 | SimClient.AddPacketHandler(PacketType.DeRezObject, _localWorld.DeRezObject); | 64 | ClientView.AddPacketHandler(PacketType.UUIDNameRequest, this.RequestUUIDName); |
65 | SimClient.AddPacketHandler(PacketType.UUIDNameRequest, this.RequestUUIDName); | ||
66 | } | 65 | } |
67 | } | 66 | } |
68 | 67 | ||
69 | #region Client Packet Handlers | 68 | #region Client Packet Handlers |
70 | 69 | ||
71 | public bool RequestUUIDName(SimClient simClient, Packet packet) | 70 | public bool RequestUUIDName(ClientView simClient, Packet packet) |
72 | { | 71 | { |
73 | System.Text.Encoding enc = System.Text.Encoding.ASCII; | 72 | System.Text.Encoding enc = System.Text.Encoding.ASCII; |
74 | Console.WriteLine(packet.ToString()); | 73 | Console.WriteLine(packet.ToString()); |
diff --git a/OpenSim.RegionServer/SimClientBase.cs b/OpenSim.RegionServer/SimClientBase.cs deleted file mode 100644 index d0dd381..0000000 --- a/OpenSim.RegionServer/SimClientBase.cs +++ /dev/null | |||
@@ -1,32 +0,0 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using libsecondlife; | ||
5 | using libsecondlife.Packets; | ||
6 | |||
7 | namespace OpenSim | ||
8 | { | ||
9 | public class SimClientBase | ||
10 | { | ||
11 | |||
12 | protected virtual void ProcessInPacket(Packet Pack) | ||
13 | { | ||
14 | |||
15 | } | ||
16 | |||
17 | protected virtual void ProcessOutPacket(Packet Pack) | ||
18 | { | ||
19 | |||
20 | } | ||
21 | |||
22 | public virtual void InPacket(Packet NewPack) | ||
23 | { | ||
24 | |||
25 | } | ||
26 | |||
27 | public virtual void OutPacket(Packet NewPack) | ||
28 | { | ||
29 | |||
30 | } | ||
31 | } | ||
32 | } | ||
diff --git a/OpenSim.RegionServer/UDPServer.cs b/OpenSim.RegionServer/UDPServer.cs index 0bab05a..3a93e66 100644 --- a/OpenSim.RegionServer/UDPServer.cs +++ b/OpenSim.RegionServer/UDPServer.cs | |||
@@ -133,7 +133,7 @@ namespace OpenSim | |||
133 | this.clientCircuits.Add(epSender, useCircuit.CircuitCode.Code); | 133 | this.clientCircuits.Add(epSender, useCircuit.CircuitCode.Code); |
134 | bool isChildAgent = false; | 134 | bool isChildAgent = false; |
135 | 135 | ||
136 | SimClient newuser = new SimClient(epSender, useCircuit, m_localWorld, _packetServer.ClientThreads, m_assetCache, m_gridServers.GridServer, this, m_inventoryCache, m_sandbox, isChildAgent, this.m_regionData, m_authenticateSessionsClass); | 136 | ClientView newuser = new ClientView(epSender, useCircuit, m_localWorld, _packetServer.ClientThreads, m_assetCache, m_gridServers.GridServer, this, m_inventoryCache, m_sandbox, isChildAgent, this.m_regionData, m_authenticateSessionsClass); |
137 | if ((this.m_gridServers.UserServer != null) && (user_accounts)) | 137 | if ((this.m_gridServers.UserServer != null) && (user_accounts)) |
138 | { | 138 | { |
139 | newuser.UserServer = this.m_gridServers.UserServer; | 139 | newuser.UserServer = this.m_gridServers.UserServer; |
diff --git a/OpenSim.RegionServer/world/Avatar.Update.cs b/OpenSim.RegionServer/world/Avatar.Update.cs index ba2965d..75f0bb4 100644 --- a/OpenSim.RegionServer/world/Avatar.Update.cs +++ b/OpenSim.RegionServer/world/Avatar.Update.cs | |||
@@ -28,9 +28,10 @@ namespace OpenSim.world | |||
28 | terse.RegionData.TimeDilation = 64096; | 28 | terse.RegionData.TimeDilation = 64096; |
29 | terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; | 29 | terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; |
30 | terse.ObjectData[0] = terseBlock; | 30 | terse.ObjectData[0] = terseBlock; |
31 | foreach (SimClient client in m_clientThreads.Values) | 31 | List<Avatar> avList = this.m_world.RequestAvatarList(); |
32 | foreach (Avatar client in avList) | ||
32 | { | 33 | { |
33 | client.OutPacket(terse); | 34 | client.SendPacketToViewer(terse); |
34 | } | 35 | } |
35 | 36 | ||
36 | updateflag = false; | 37 | updateflag = false; |
@@ -51,9 +52,10 @@ namespace OpenSim.world | |||
51 | terse.RegionData.TimeDilation = 64096; | 52 | terse.RegionData.TimeDilation = 64096; |
52 | terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; | 53 | terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; |
53 | terse.ObjectData[0] = terseBlock; | 54 | terse.ObjectData[0] = terseBlock; |
54 | foreach (SimClient client in m_clientThreads.Values) | 55 | List<Avatar> avList = this.m_world.RequestAvatarList(); |
56 | foreach (Avatar client in avList) | ||
55 | { | 57 | { |
56 | client.OutPacket(terse); | 58 | client.SendPacketToViewer(terse); |
57 | } | 59 | } |
58 | _updateCount = 0; | 60 | _updateCount = 0; |
59 | } | 61 | } |
@@ -134,15 +136,13 @@ namespace OpenSim.world | |||
134 | byte[] pb = pos2.GetBytes(); | 136 | byte[] pb = pos2.GetBytes(); |
135 | Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length); | 137 | Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length); |
136 | m_world._localNumber++; | 138 | m_world._localNumber++; |
137 | foreach (SimClient client in m_clientThreads.Values) | 139 | |
140 | List<Avatar> avList = this.m_world.RequestAvatarList(); | ||
141 | foreach (Avatar client in avList) | ||
138 | { | 142 | { |
139 | client.OutPacket(objupdate); | 143 | client.SendPacketToViewer(objupdate); |
140 | if (client.AgentID != ControllingClient.AgentID) | 144 | if (client.ControllingClient.AgentID != this.ControllingClient.AgentID) |
141 | { | 145 | { |
142 | //the below line is already in Simclient.cs at line number 245 , directly below the call to this method | ||
143 | //if there is a problem/bug with that , then lets fix it there rather than duplicating it here | ||
144 | //client.ClientAvatar.SendAppearanceToOtherAgent(this.ControllingClient); | ||
145 | |||
146 | SendAppearanceToOtherAgent(client); | 146 | SendAppearanceToOtherAgent(client); |
147 | } | 147 | } |
148 | } | 148 | } |
@@ -169,30 +169,12 @@ namespace OpenSim.world | |||
169 | ControllingClient.OutPacket(aw); | 169 | ControllingClient.OutPacket(aw); |
170 | } | 170 | } |
171 | 171 | ||
172 | public void SendAppearanceToOtherAgent(SimClient userInfo) | 172 | public void SendAppearanceToOtherAgent(Avatar avatarInfo) |
173 | { | 173 | { |
174 | AvatarAppearancePacket avp = new AvatarAppearancePacket(); | 174 | AvatarAppearancePacket avp = new AvatarAppearancePacket(); |
175 | avp.VisualParam = new AvatarAppearancePacket.VisualParamBlock[218]; | 175 | avp.VisualParam = new AvatarAppearancePacket.VisualParamBlock[218]; |
176 | avp.ObjectData.TextureEntry = this.avatarAppearanceTexture.ToBytes(); | 176 | avp.ObjectData.TextureEntry = this.avatarAppearanceTexture.ToBytes(); |
177 | 177 | ||
178 | //a wearable update packets should only be sent about the viewers/agents own avatar not for other avatars | ||
179 | //but it seems that the following code only created the packets and never actually sent them anyway | ||
180 | /*AgentWearablesUpdatePacket aw = new AgentWearablesUpdatePacket(); | ||
181 | aw.AgentData.AgentID = this.ControllingClient.AgentID; | ||
182 | aw.AgentData.SessionID = userInfo.SessionID; | ||
183 | aw.AgentData.SerialNum = 0; //removed the use of a random number as a random number could be less than the last number, should have a counter variable for this | ||
184 | |||
185 | aw.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[13]; | ||
186 | AgentWearablesUpdatePacket.WearableDataBlock awb; | ||
187 | for (int i = 0; i < 13; i++) | ||
188 | { | ||
189 | awb = new AgentWearablesUpdatePacket.WearableDataBlock(); | ||
190 | awb.WearableType = (byte)i; | ||
191 | awb.AssetID = this.Wearables[i].AssetID; | ||
192 | awb.ItemID = this.Wearables[i].ItemID; | ||
193 | aw.WearableData[i] = awb; | ||
194 | }*/ | ||
195 | |||
196 | AvatarAppearancePacket.VisualParamBlock avblock = null; | 178 | AvatarAppearancePacket.VisualParamBlock avblock = null; |
197 | for (int i = 0; i < 218; i++) | 179 | for (int i = 0; i < 218; i++) |
198 | { | 180 | { |
@@ -203,7 +185,7 @@ namespace OpenSim.world | |||
203 | 185 | ||
204 | avp.Sender.IsTrial = false; | 186 | avp.Sender.IsTrial = false; |
205 | avp.Sender.ID = ControllingClient.AgentID; | 187 | avp.Sender.ID = ControllingClient.AgentID; |
206 | userInfo.OutPacket(avp); | 188 | avatarInfo.SendPacketToViewer(avp); |
207 | } | 189 | } |
208 | 190 | ||
209 | public void SetAppearance(AgentSetAppearancePacket appear) | 191 | public void SetAppearance(AgentSetAppearancePacket appear) |
@@ -214,9 +196,11 @@ namespace OpenSim.world | |||
214 | { | 196 | { |
215 | this.visualParams[i] = appear.VisualParam[i].ParamValue; | 197 | this.visualParams[i] = appear.VisualParam[i].ParamValue; |
216 | } | 198 | } |
217 | foreach (SimClient client in m_clientThreads.Values) | 199 | |
200 | List<Avatar> avList = this.m_world.RequestAvatarList(); | ||
201 | foreach (Avatar client in avList) | ||
218 | { | 202 | { |
219 | if (client.AgentID != ControllingClient.AgentID) | 203 | if (client.ControllingClient.AgentID != this.ControllingClient.AgentID) |
220 | { | 204 | { |
221 | SendAppearanceToOtherAgent(client); | 205 | SendAppearanceToOtherAgent(client); |
222 | } | 206 | } |
@@ -320,11 +304,12 @@ namespace OpenSim.world | |||
320 | ani.AnimationList[0].AnimID = this.current_anim; | 304 | ani.AnimationList[0].AnimID = this.current_anim; |
321 | ani.AnimationList[0].AnimSequenceID = this.anim_seq; | 305 | ani.AnimationList[0].AnimSequenceID = this.anim_seq; |
322 | 306 | ||
323 | //ControllingClient.OutPacket(ani); | 307 | List<Avatar> avList = this.m_world.RequestAvatarList(); |
324 | foreach (SimClient client in m_clientThreads.Values) | 308 | foreach (Avatar client in avList) |
325 | { | 309 | { |
326 | client.OutPacket(ani); | 310 | client.SendPacketToViewer(ani); |
327 | } | 311 | } |
312 | |||
328 | } | 313 | } |
329 | 314 | ||
330 | } | 315 | } |
diff --git a/OpenSim.RegionServer/world/Avatar.cs b/OpenSim.RegionServer/world/Avatar.cs index c684c45..55e5ae4 100644 --- a/OpenSim.RegionServer/world/Avatar.cs +++ b/OpenSim.RegionServer/world/Avatar.cs | |||
@@ -16,7 +16,7 @@ namespace OpenSim.world | |||
16 | public static AvatarAnimations Animations; | 16 | public static AvatarAnimations Animations; |
17 | public string firstname; | 17 | public string firstname; |
18 | public string lastname; | 18 | public string lastname; |
19 | public SimClient ControllingClient; | 19 | public ClientView ControllingClient; |
20 | public LLUUID current_anim; | 20 | public LLUUID current_anim; |
21 | public int anim_seq; | 21 | public int anim_seq; |
22 | private static libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock AvatarTemplate; | 22 | private static libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock AvatarTemplate; |
@@ -30,16 +30,16 @@ namespace OpenSim.world | |||
30 | private AvatarWearable[] Wearables; | 30 | private AvatarWearable[] Wearables; |
31 | private LLVector3 positionLastFrame = new LLVector3(0, 0, 0); | 31 | private LLVector3 positionLastFrame = new LLVector3(0, 0, 0); |
32 | private ulong m_regionHandle; | 32 | private ulong m_regionHandle; |
33 | private Dictionary<uint, SimClient> m_clientThreads; | 33 | //private Dictionary<uint, ClientView> m_clientThreads; |
34 | private string m_regionName; | 34 | private string m_regionName; |
35 | private ushort m_regionWaterHeight; | 35 | private ushort m_regionWaterHeight; |
36 | private bool m_regionTerraform; | 36 | private bool m_regionTerraform; |
37 | //private bool childShadowAvatar = false; | 37 | //private bool childShadowAvatar = false; |
38 | 38 | ||
39 | public Avatar(SimClient TheClient, World world, string regionName, Dictionary<uint, SimClient> clientThreads, ulong regionHandle, bool regionTerraform, ushort regionWater) | 39 | public Avatar(ClientView TheClient, World world, string regionName, Dictionary<uint, ClientView> clientThreads, ulong regionHandle, bool regionTerraform, ushort regionWater) |
40 | { | 40 | { |
41 | m_world = world; | 41 | m_world = world; |
42 | m_clientThreads = clientThreads; | 42 | // m_clientThreads = clientThreads; |
43 | m_regionName = regionName; | 43 | m_regionName = regionName; |
44 | m_regionHandle = regionHandle; | 44 | m_regionHandle = regionHandle; |
45 | m_regionTerraform = regionTerraform; | 45 | m_regionTerraform = regionTerraform; |
diff --git a/OpenSim.RegionServer/world/Primitive.cs b/OpenSim.RegionServer/world/Primitive.cs index 4f861f7..e048a9e 100644 --- a/OpenSim.RegionServer/world/Primitive.cs +++ b/OpenSim.RegionServer/world/Primitive.cs | |||
@@ -22,7 +22,7 @@ namespace OpenSim.world | |||
22 | private bool physicsEnabled = false; | 22 | private bool physicsEnabled = false; |
23 | private bool physicstest = false; | 23 | private bool physicstest = false; |
24 | private LLVector3 positionLastFrame = new LLVector3(0, 0, 0); | 24 | private LLVector3 positionLastFrame = new LLVector3(0, 0, 0); |
25 | private Dictionary<uint, SimClient> m_clientThreads; | 25 | private Dictionary<uint, ClientView> m_clientThreads; |
26 | private ulong m_regionHandle; | 26 | private ulong m_regionHandle; |
27 | private const uint FULL_MASK_PERMISSIONS = 2147483647; | 27 | private const uint FULL_MASK_PERMISSIONS = 2147483647; |
28 | 28 | ||
@@ -75,7 +75,7 @@ namespace OpenSim.world | |||
75 | } | 75 | } |
76 | } | 76 | } |
77 | 77 | ||
78 | public Primitive(Dictionary<uint, SimClient> clientThreads, ulong regionHandle, World world) | 78 | public Primitive(Dictionary<uint, ClientView> clientThreads, ulong regionHandle, World world) |
79 | { | 79 | { |
80 | mesh_cutbegin = 0.0f; | 80 | mesh_cutbegin = 0.0f; |
81 | mesh_cutend = 1.0f; | 81 | mesh_cutend = 1.0f; |
@@ -104,7 +104,7 @@ namespace OpenSim.world | |||
104 | return this.primData.ToBytes(); | 104 | return this.primData.ToBytes(); |
105 | } | 105 | } |
106 | 106 | ||
107 | public void GetProperites(SimClient client) | 107 | public void GetProperites(ClientView client) |
108 | { | 108 | { |
109 | ObjectPropertiesPacket proper = new ObjectPropertiesPacket(); | 109 | ObjectPropertiesPacket proper = new ObjectPropertiesPacket(); |
110 | proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1]; | 110 | proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1]; |
@@ -164,7 +164,7 @@ namespace OpenSim.world | |||
164 | } | 164 | } |
165 | if (this.newPrimFlag) | 165 | if (this.newPrimFlag) |
166 | { | 166 | { |
167 | foreach (SimClient client in m_clientThreads.Values) | 167 | foreach (ClientView client in m_clientThreads.Values) |
168 | { | 168 | { |
169 | client.OutPacket(OurPacket); | 169 | client.OutPacket(OurPacket); |
170 | } | 170 | } |
@@ -177,7 +177,7 @@ namespace OpenSim.world | |||
177 | terse.RegionData.TimeDilation = 64096; | 177 | terse.RegionData.TimeDilation = 64096; |
178 | terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; | 178 | terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; |
179 | terse.ObjectData[0] = this.CreateImprovedBlock(); | 179 | terse.ObjectData[0] = this.CreateImprovedBlock(); |
180 | foreach (SimClient client in m_clientThreads.Values) | 180 | foreach (ClientView client in m_clientThreads.Values) |
181 | { | 181 | { |
182 | client.OutPacket(terse); | 182 | client.OutPacket(terse); |
183 | } | 183 | } |
@@ -185,7 +185,7 @@ namespace OpenSim.world | |||
185 | } | 185 | } |
186 | else if (this.dirtyFlag) | 186 | else if (this.dirtyFlag) |
187 | { | 187 | { |
188 | foreach (SimClient client in m_clientThreads.Values) | 188 | foreach (ClientView client in m_clientThreads.Values) |
189 | { | 189 | { |
190 | UpdateClient(client); | 190 | UpdateClient(client); |
191 | } | 191 | } |
@@ -202,7 +202,7 @@ namespace OpenSim.world | |||
202 | terse.RegionData.TimeDilation = 64096; | 202 | terse.RegionData.TimeDilation = 64096; |
203 | terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; | 203 | terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; |
204 | terse.ObjectData[0] = this.CreateImprovedBlock(); | 204 | terse.ObjectData[0] = this.CreateImprovedBlock(); |
205 | foreach (SimClient client in m_clientThreads.Values) | 205 | foreach (ClientView client in m_clientThreads.Values) |
206 | { | 206 | { |
207 | client.OutPacket(terse); | 207 | client.OutPacket(terse); |
208 | } | 208 | } |
@@ -220,7 +220,7 @@ namespace OpenSim.world | |||
220 | } | 220 | } |
221 | } | 221 | } |
222 | 222 | ||
223 | public void UpdateClient(SimClient RemoteClient) | 223 | public void UpdateClient(ClientView RemoteClient) |
224 | { | 224 | { |
225 | 225 | ||
226 | LLVector3 lPos; | 226 | LLVector3 lPos; |
diff --git a/OpenSim.RegionServer/world/Primitive2.cs b/OpenSim.RegionServer/world/Primitive2.cs index 3b39456..6d071d4 100644 --- a/OpenSim.RegionServer/world/Primitive2.cs +++ b/OpenSim.RegionServer/world/Primitive2.cs | |||
@@ -16,7 +16,7 @@ namespace OpenSim.world | |||
16 | protected PrimData primData; | 16 | protected PrimData primData; |
17 | //private ObjectUpdatePacket OurPacket; | 17 | //private ObjectUpdatePacket OurPacket; |
18 | private LLVector3 positionLastFrame = new LLVector3(0, 0, 0); | 18 | private LLVector3 positionLastFrame = new LLVector3(0, 0, 0); |
19 | private Dictionary<uint, SimClient> m_clientThreads; | 19 | private Dictionary<uint, ClientView> m_clientThreads; |
20 | private ulong m_regionHandle; | 20 | private ulong m_regionHandle; |
21 | private const uint FULL_MASK_PERMISSIONS = 2147483647; | 21 | private const uint FULL_MASK_PERMISSIONS = 2147483647; |
22 | private bool physicsEnabled = false; | 22 | private bool physicsEnabled = false; |
@@ -58,7 +58,7 @@ namespace OpenSim.world | |||
58 | } | 58 | } |
59 | #endregion | 59 | #endregion |
60 | 60 | ||
61 | public Primitive2(Dictionary<uint, SimClient> clientThreads, ulong regionHandle, World world) | 61 | public Primitive2(Dictionary<uint, ClientView> clientThreads, ulong regionHandle, World world) |
62 | { | 62 | { |
63 | m_clientThreads = clientThreads; | 63 | m_clientThreads = clientThreads; |
64 | m_regionHandle = regionHandle; | 64 | m_regionHandle = regionHandle; |
@@ -66,6 +66,17 @@ namespace OpenSim.world | |||
66 | inventoryItems = new Dictionary<LLUUID, InventoryItem>(); | 66 | inventoryItems = new Dictionary<LLUUID, InventoryItem>(); |
67 | } | 67 | } |
68 | 68 | ||
69 | public Primitive2(Dictionary<uint, ClientView> clientThreads, ulong regionHandle, World world, LLUUID owner) | ||
70 | { | ||
71 | m_clientThreads = clientThreads; | ||
72 | m_regionHandle = regionHandle; | ||
73 | m_world = world; | ||
74 | inventoryItems = new Dictionary<LLUUID, InventoryItem>(); | ||
75 | this.primData = new PrimData(); | ||
76 | this.primData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; | ||
77 | this.primData.OwnerID = owner; | ||
78 | } | ||
79 | |||
69 | public byte[] GetByteArray() | 80 | public byte[] GetByteArray() |
70 | { | 81 | { |
71 | byte[] result = null; | 82 | byte[] result = null; |
@@ -159,7 +170,7 @@ namespace OpenSim.world | |||
159 | 170 | ||
160 | } | 171 | } |
161 | 172 | ||
162 | public void GetProperites(SimClient client) | 173 | public void GetProperites(ClientView client) |
163 | { | 174 | { |
164 | ObjectPropertiesPacket proper = new ObjectPropertiesPacket(); | 175 | ObjectPropertiesPacket proper = new ObjectPropertiesPacket(); |
165 | proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1]; | 176 | proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1]; |
@@ -202,12 +213,12 @@ namespace OpenSim.world | |||
202 | return null; | 213 | return null; |
203 | } | 214 | } |
204 | 215 | ||
205 | public void RequestInventoryInfo(SimClient simClient, RequestTaskInventoryPacket packet) | 216 | public void RequestInventoryInfo(ClientView simClient, RequestTaskInventoryPacket packet) |
206 | { | 217 | { |
207 | 218 | ||
208 | } | 219 | } |
209 | 220 | ||
210 | public void RequestXferInventory(SimClient simClient, ulong xferID) | 221 | public void RequestXferInventory(ClientView simClient, ulong xferID) |
211 | { | 222 | { |
212 | //will only currently work if the total size of the inventory data array is under about 1000 bytes | 223 | //will only currently work if the total size of the inventory data array is under about 1000 bytes |
213 | SendXferPacketPacket send = new SendXferPacketPacket(); | 224 | SendXferPacketPacket send = new SendXferPacketPacket(); |
@@ -246,7 +257,7 @@ namespace OpenSim.world | |||
246 | #region Update viewers Methods | 257 | #region Update viewers Methods |
247 | 258 | ||
248 | //should change these mehtods, so that outgoing packets are sent through the avatar class | 259 | //should change these mehtods, so that outgoing packets are sent through the avatar class |
249 | public void SendFullUpdateToClient(SimClient remoteClient) | 260 | public void SendFullUpdateToClient(ClientView remoteClient) |
250 | { | 261 | { |
251 | LLVector3 lPos; | 262 | LLVector3 lPos; |
252 | if (this._physActor != null && this.physicsEnabled) | 263 | if (this._physActor != null && this.physicsEnabled) |
@@ -273,7 +284,7 @@ namespace OpenSim.world | |||
273 | 284 | ||
274 | } | 285 | } |
275 | 286 | ||
276 | public void SendTerseUpdateToClient(SimClient RemoteClient) | 287 | public void SendTerseUpdateToClient(ClientView RemoteClient) |
277 | { | 288 | { |
278 | 289 | ||
279 | } | 290 | } |
@@ -316,7 +327,7 @@ namespace OpenSim.world | |||
316 | PData.PathTwist = addPacket.ObjectData.PathTwist; | 327 | PData.PathTwist = addPacket.ObjectData.PathTwist; |
317 | PData.PathTwistBegin = addPacket.ObjectData.PathTwistBegin; | 328 | PData.PathTwistBegin = addPacket.ObjectData.PathTwistBegin; |
318 | LLVector3 pos1 = addPacket.ObjectData.RayEnd; | 329 | LLVector3 pos1 = addPacket.ObjectData.RayEnd; |
319 | this.primData.FullID = this.uuid = LLUUID.Random(); | 330 | this.primData.FullID = this.uuid = LLUUID.Random(); |
320 | this.localid = (uint)(localID); | 331 | this.localid = (uint)(localID); |
321 | this.primData.Position = this.Pos = pos1; | 332 | this.primData.Position = this.Pos = pos1; |
322 | } | 333 | } |
diff --git a/OpenSim.RegionServer/world/SceneObject.cs b/OpenSim.RegionServer/world/SceneObject.cs index 5b5a7b2..a846fb5 100644 --- a/OpenSim.RegionServer/world/SceneObject.cs +++ b/OpenSim.RegionServer/world/SceneObject.cs | |||
@@ -15,7 +15,7 @@ namespace OpenSim.world | |||
15 | { | 15 | { |
16 | private LLUUID rootUUID; | 16 | private LLUUID rootUUID; |
17 | private Dictionary<LLUUID, Primitive2> ChildPrimitives = new Dictionary<LLUUID, Primitive2>(); | 17 | private Dictionary<LLUUID, Primitive2> ChildPrimitives = new Dictionary<LLUUID, Primitive2>(); |
18 | private Dictionary<uint, SimClient> m_clientThreads; | 18 | private Dictionary<uint, ClientView> m_clientThreads; |
19 | private World m_world; | 19 | private World m_world; |
20 | 20 | ||
21 | public SceneObject() | 21 | public SceneObject() |
@@ -42,7 +42,7 @@ namespace OpenSim.world | |||
42 | 42 | ||
43 | } | 43 | } |
44 | 44 | ||
45 | public void GetProperites(SimClient client) | 45 | public void GetProperites(ClientView client) |
46 | { | 46 | { |
47 | /* | 47 | /* |
48 | ObjectPropertiesPacket proper = new ObjectPropertiesPacket(); | 48 | ObjectPropertiesPacket proper = new ObjectPropertiesPacket(); |
diff --git a/OpenSim.RegionServer/world/World.PacketHandlers.cs b/OpenSim.RegionServer/world/World.PacketHandlers.cs index 175b777..27f200f 100644 --- a/OpenSim.RegionServer/world/World.PacketHandlers.cs +++ b/OpenSim.RegionServer/world/World.PacketHandlers.cs | |||
@@ -16,7 +16,7 @@ namespace OpenSim.world | |||
16 | public partial class World | 16 | public partial class World |
17 | { | 17 | { |
18 | 18 | ||
19 | public bool ModifyTerrain(SimClient simClient, Packet packet) | 19 | public bool ModifyTerrain(ClientView simClient, Packet packet) |
20 | { | 20 | { |
21 | ModifyLandPacket modify = (ModifyLandPacket)packet; | 21 | ModifyLandPacket modify = (ModifyLandPacket)packet; |
22 | 22 | ||
@@ -42,68 +42,44 @@ namespace OpenSim.world | |||
42 | return true; | 42 | return true; |
43 | } | 43 | } |
44 | 44 | ||
45 | public bool SimChat(SimClient simClient, Packet packet) | 45 | public void SimChat(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID) |
46 | { | 46 | { |
47 | System.Text.Encoding enc = System.Text.Encoding.ASCII; | 47 | foreach (ClientView client in m_clientThreads.Values) |
48 | ChatFromViewerPacket inchatpack = (ChatFromViewerPacket)packet; | ||
49 | if (Util.FieldToString(inchatpack.ChatData.Message) == "") | ||
50 | { | ||
51 | //empty message so don't bother with it | ||
52 | return true; | ||
53 | } | ||
54 | |||
55 | string fromName = simClient.ClientAvatar.firstname + " " + simClient.ClientAvatar.lastname; | ||
56 | byte[] message = inchatpack.ChatData.Message; | ||
57 | byte type = inchatpack.ChatData.Type; | ||
58 | LLVector3 fromPos = simClient.ClientAvatar.Pos; | ||
59 | LLUUID fromAgentID = simClient.AgentID; | ||
60 | |||
61 | libsecondlife.Packets.ChatFromSimulatorPacket reply = new ChatFromSimulatorPacket(); | ||
62 | reply.ChatData.Audible = 1; | ||
63 | reply.ChatData.Message = message; | ||
64 | reply.ChatData.ChatType = type; | ||
65 | reply.ChatData.SourceType = 1; | ||
66 | reply.ChatData.Position = fromPos; | ||
67 | reply.ChatData.FromName = enc.GetBytes(fromName + "\0"); | ||
68 | reply.ChatData.OwnerID = fromAgentID; | ||
69 | reply.ChatData.SourceID = fromAgentID; | ||
70 | |||
71 | foreach (SimClient client in m_clientThreads.Values) | ||
72 | { | 48 | { |
73 | // int dis = Util.fast_distance2d((int)(client.ClientAvatar.Pos.X - simClient.ClientAvatar.Pos.X), (int)(client.ClientAvatar.Pos.Y - simClient.ClientAvatar.Pos.Y)); | 49 | // int dis = Util.fast_distance2d((int)(client.ClientAvatar.Pos.X - simClient.ClientAvatar.Pos.X), (int)(client.ClientAvatar.Pos.Y - simClient.ClientAvatar.Pos.Y)); |
74 | int dis = (int)client.ClientAvatar.Pos.GetDistanceTo(simClient.ClientAvatar.Pos); | 50 | int dis = (int)client.ClientAvatar.Pos.GetDistanceTo(fromPos); |
75 | 51 | ||
76 | switch (inchatpack.ChatData.Type) | 52 | switch (type) |
77 | { | 53 | { |
78 | case 0: // Whisper | 54 | case 0: // Whisper |
79 | if ((dis < 10) && (dis > -10)) | 55 | if ((dis < 10) && (dis > -10)) |
80 | { | 56 | { |
81 | client.OutPacket(reply); | 57 | //should change so the message is sent through the avatar rather than direct to the ClientView |
58 | client.SendChatMessage(message, type, fromPos, fromName, fromAgentID); | ||
82 | } | 59 | } |
83 | break; | 60 | break; |
84 | case 1: // Say | 61 | case 1: // Say |
85 | if ((dis < 30) && (dis > -30)) | 62 | if ((dis < 30) && (dis > -30)) |
86 | { | 63 | { |
87 | client.OutPacket(reply); | 64 | client.SendChatMessage(message, type, fromPos, fromName, fromAgentID); |
88 | } | 65 | } |
89 | break; | 66 | break; |
90 | case 2: // Shout | 67 | case 2: // Shout |
91 | if ((dis < 100) && (dis > -100)) | 68 | if ((dis < 100) && (dis > -100)) |
92 | { | 69 | { |
93 | client.OutPacket(reply); | 70 | client.SendChatMessage(message, type, fromPos, fromName, fromAgentID); |
94 | } | 71 | } |
95 | break; | 72 | break; |
96 | 73 | ||
97 | case 0xff: // Broadcast | 74 | case 0xff: // Broadcast |
98 | client.OutPacket(reply); | 75 | client.SendChatMessage(message, type, fromPos, fromName, fromAgentID); |
99 | break; | 76 | break; |
100 | } | 77 | } |
101 | 78 | ||
102 | } | 79 | } |
103 | return true; | ||
104 | } | 80 | } |
105 | 81 | ||
106 | public bool RezObject(SimClient simClient, Packet packet) | 82 | public bool RezObject(ClientView simClient, Packet packet) |
107 | { | 83 | { |
108 | RezObjectPacket rezPacket = (RezObjectPacket)packet; | 84 | RezObjectPacket rezPacket = (RezObjectPacket)packet; |
109 | AgentInventory inven = this._inventoryCache.GetAgentsInventory(simClient.AgentID); | 85 | AgentInventory inven = this._inventoryCache.GetAgentsInventory(simClient.AgentID); |
@@ -126,7 +102,7 @@ namespace OpenSim.world | |||
126 | return true; | 102 | return true; |
127 | } | 103 | } |
128 | 104 | ||
129 | public bool DeRezObject(SimClient simClient, Packet packet) | 105 | public bool DeRezObject(ClientView simClient, Packet packet) |
130 | { | 106 | { |
131 | DeRezObjectPacket DeRezPacket = (DeRezObjectPacket)packet; | 107 | DeRezObjectPacket DeRezPacket = (DeRezObjectPacket)packet; |
132 | 108 | ||
@@ -151,7 +127,7 @@ namespace OpenSim.world | |||
151 | kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1]; | 127 | kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1]; |
152 | kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock(); | 128 | kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock(); |
153 | kill.ObjectData[0].ID = ent.localid; | 129 | kill.ObjectData[0].ID = ent.localid; |
154 | foreach (SimClient client in m_clientThreads.Values) | 130 | foreach (ClientView client in m_clientThreads.Values) |
155 | { | 131 | { |
156 | client.OutPacket(kill); | 132 | client.OutPacket(kill); |
157 | } | 133 | } |
@@ -201,7 +177,7 @@ namespace OpenSim.world | |||
201 | kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1]; | 177 | kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1]; |
202 | kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock(); | 178 | kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock(); |
203 | kill.ObjectData[0].ID = selectedEnt.localid; | 179 | kill.ObjectData[0].ID = selectedEnt.localid; |
204 | foreach (SimClient client in m_clientThreads.Values) | 180 | foreach (ClientView client in m_clientThreads.Values) |
205 | { | 181 | { |
206 | client.OutPacket(kill); | 182 | client.OutPacket(kill); |
207 | } | 183 | } |
@@ -215,7 +191,7 @@ namespace OpenSim.world | |||
215 | return true; | 191 | return true; |
216 | } | 192 | } |
217 | 193 | ||
218 | public void RequestMapBlock(SimClient simClient, int minX, int minY, int maxX, int maxY) | 194 | public void RequestMapBlock(ClientView simClient, int minX, int minY, int maxX, int maxY) |
219 | { | 195 | { |
220 | System.Text.Encoding _enc = System.Text.Encoding.ASCII; | 196 | System.Text.Encoding _enc = System.Text.Encoding.ASCII; |
221 | if (((m_regInfo.RegionLocX > minX) && (m_regInfo.RegionLocX < maxX)) && ((m_regInfo.RegionLocY > minY) && (m_regInfo.RegionLocY < maxY))) | 197 | if (((m_regInfo.RegionLocX > minX) && (m_regInfo.RegionLocX < maxX)) && ((m_regInfo.RegionLocY > minY) && (m_regInfo.RegionLocY < maxY))) |
diff --git a/OpenSim.RegionServer/world/World.cs b/OpenSim.RegionServer/world/World.cs index 983e66d..c90e3f6 100644 --- a/OpenSim.RegionServer/world/World.cs +++ b/OpenSim.RegionServer/world/World.cs | |||
@@ -57,7 +57,7 @@ namespace OpenSim.world | |||
57 | /// <param name="clientThreads">Dictionary to contain client threads</param> | 57 | /// <param name="clientThreads">Dictionary to contain client threads</param> |
58 | /// <param name="regionHandle">Region Handle for this region</param> | 58 | /// <param name="regionHandle">Region Handle for this region</param> |
59 | /// <param name="regionName">Region Name for this region</param> | 59 | /// <param name="regionName">Region Name for this region</param> |
60 | public World(Dictionary<uint, SimClient> clientThreads, RegionInfo regInfo, ulong regionHandle, string regionName) | 60 | public World(Dictionary<uint, ClientView> clientThreads, RegionInfo regInfo, ulong regionHandle, string regionName) |
61 | { | 61 | { |
62 | try | 62 | try |
63 | { | 63 | { |
@@ -324,7 +324,7 @@ namespace OpenSim.world | |||
324 | } | 324 | } |
325 | this.localStorage.SaveMap(this.Terrain.getHeights1D()); | 325 | this.localStorage.SaveMap(this.Terrain.getHeights1D()); |
326 | 326 | ||
327 | foreach (SimClient client in m_clientThreads.Values) | 327 | foreach (ClientView client in m_clientThreads.Values) |
328 | { | 328 | { |
329 | this.SendLayerData(client); | 329 | this.SendLayerData(client); |
330 | } | 330 | } |
@@ -355,7 +355,7 @@ namespace OpenSim.world | |||
355 | } | 355 | } |
356 | this.localStorage.SaveMap(this.Terrain.getHeights1D()); | 356 | this.localStorage.SaveMap(this.Terrain.getHeights1D()); |
357 | 357 | ||
358 | foreach (SimClient client in m_clientThreads.Values) | 358 | foreach (ClientView client in m_clientThreads.Values) |
359 | { | 359 | { |
360 | this.SendLayerData(client); | 360 | this.SendLayerData(client); |
361 | } | 361 | } |
@@ -389,7 +389,7 @@ namespace OpenSim.world | |||
389 | } | 389 | } |
390 | this.localStorage.SaveMap(this.Terrain.getHeights1D()); | 390 | this.localStorage.SaveMap(this.Terrain.getHeights1D()); |
391 | 391 | ||
392 | foreach (SimClient client in m_clientThreads.Values) | 392 | foreach (ClientView client in m_clientThreads.Values) |
393 | { | 393 | { |
394 | this.SendLayerData(pointx, pointy, client); | 394 | this.SendLayerData(pointx, pointy, client); |
395 | } | 395 | } |
@@ -437,7 +437,7 @@ namespace OpenSim.world | |||
437 | /// Sends prims to a client | 437 | /// Sends prims to a client |
438 | /// </summary> | 438 | /// </summary> |
439 | /// <param name="RemoteClient">Client to send to</param> | 439 | /// <param name="RemoteClient">Client to send to</param> |
440 | public void GetInitialPrims(SimClient RemoteClient) | 440 | public void GetInitialPrims(ClientView RemoteClient) |
441 | { | 441 | { |
442 | try | 442 | try |
443 | { | 443 | { |
@@ -495,7 +495,7 @@ namespace OpenSim.world | |||
495 | } | 495 | } |
496 | } | 496 | } |
497 | 497 | ||
498 | public void AddNewPrim(ObjectAddPacket addPacket, SimClient AgentClient) | 498 | public void AddNewPrim(ObjectAddPacket addPacket, ClientView AgentClient) |
499 | { | 499 | { |
500 | AddNewPrim(addPacket, AgentClient.AgentID); | 500 | AddNewPrim(addPacket, AgentClient.AgentID); |
501 | } | 501 | } |
@@ -530,8 +530,9 @@ namespace OpenSim.world | |||
530 | 530 | ||
531 | #region Add/Remove Avatar Methods | 531 | #region Add/Remove Avatar Methods |
532 | 532 | ||
533 | public override void AddViewerAgent(SimClient agentClient) | 533 | public override void AddViewerAgent(ClientView agentClient) |
534 | { | 534 | { |
535 | agentClient.OnChatFromViewer += new ClientView.ChatFromViewer(this.SimChat); | ||
535 | try | 536 | try |
536 | { | 537 | { |
537 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "World.cs:AddViewerAgent() - Creating new avatar for remote viewer agent"); | 538 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "World.cs:AddViewerAgent() - Creating new avatar for remote viewer agent"); |
@@ -576,7 +577,7 @@ namespace OpenSim.world | |||
576 | } | 577 | } |
577 | } | 578 | } |
578 | 579 | ||
579 | public override void RemoveViewerAgent(SimClient agentClient) | 580 | public override void RemoveViewerAgent(ClientView agentClient) |
580 | { | 581 | { |
581 | try | 582 | try |
582 | { | 583 | { |
@@ -600,6 +601,23 @@ namespace OpenSim.world | |||
600 | } | 601 | } |
601 | #endregion | 602 | #endregion |
602 | 603 | ||
604 | #region Request Avatars List Methods | ||
605 | //The idea is to have a group of method that return a list of avatars meeting some requirement | ||
606 | // ie it could be all Avatars within a certain range of the calling prim/avatar. | ||
607 | |||
608 | public List<Avatar> RequestAvatarList() | ||
609 | { | ||
610 | List<Avatar> result = new List<Avatar>(); | ||
611 | |||
612 | foreach (Avatar avatar in Avatars.Values) | ||
613 | { | ||
614 | result.Add(avatar); | ||
615 | } | ||
616 | |||
617 | return result; | ||
618 | } | ||
619 | #endregion | ||
620 | |||
603 | #region ShutDown | 621 | #region ShutDown |
604 | /// <summary> | 622 | /// <summary> |
605 | /// Tidy before shutdown | 623 | /// Tidy before shutdown |
diff --git a/OpenSim.RegionServer/world/WorldBase.cs b/OpenSim.RegionServer/world/WorldBase.cs index b8c086d..edc5518 100644 --- a/OpenSim.RegionServer/world/WorldBase.cs +++ b/OpenSim.RegionServer/world/WorldBase.cs | |||
@@ -20,7 +20,7 @@ namespace OpenSim.world | |||
20 | public class WorldBase | 20 | public class WorldBase |
21 | { | 21 | { |
22 | public Dictionary<libsecondlife.LLUUID, Entity> Entities; | 22 | public Dictionary<libsecondlife.LLUUID, Entity> Entities; |
23 | protected Dictionary<uint, SimClient> m_clientThreads; | 23 | protected Dictionary<uint, ClientView> m_clientThreads; |
24 | protected ulong m_regionHandle; | 24 | protected ulong m_regionHandle; |
25 | protected string m_regionName; | 25 | protected string m_regionName; |
26 | protected InventoryCache _inventoryCache; | 26 | protected InventoryCache _inventoryCache; |
@@ -90,7 +90,7 @@ namespace OpenSim.world | |||
90 | /// Send the region heightmap to the client | 90 | /// Send the region heightmap to the client |
91 | /// </summary> | 91 | /// </summary> |
92 | /// <param name="RemoteClient">Client to send to</param> | 92 | /// <param name="RemoteClient">Client to send to</param> |
93 | public virtual void SendLayerData(SimClient RemoteClient) | 93 | public virtual void SendLayerData(ClientView RemoteClient) |
94 | { | 94 | { |
95 | try | 95 | try |
96 | { | 96 | { |
@@ -122,7 +122,7 @@ namespace OpenSim.world | |||
122 | /// <param name="px">Patch coordinate (x) 0..16</param> | 122 | /// <param name="px">Patch coordinate (x) 0..16</param> |
123 | /// <param name="py">Patch coordinate (y) 0..16</param> | 123 | /// <param name="py">Patch coordinate (y) 0..16</param> |
124 | /// <param name="RemoteClient">The client to send to</param> | 124 | /// <param name="RemoteClient">The client to send to</param> |
125 | public void SendLayerData(int px, int py, SimClient RemoteClient) | 125 | public void SendLayerData(int px, int py, ClientView RemoteClient) |
126 | { | 126 | { |
127 | try | 127 | try |
128 | { | 128 | { |
@@ -148,7 +148,7 @@ namespace OpenSim.world | |||
148 | /// Add a new Agent's avatar | 148 | /// Add a new Agent's avatar |
149 | /// </summary> | 149 | /// </summary> |
150 | /// <param name="agentClient"></param> | 150 | /// <param name="agentClient"></param> |
151 | public virtual void AddViewerAgent(SimClient agentClient) | 151 | public virtual void AddViewerAgent(ClientView agentClient) |
152 | { | 152 | { |
153 | 153 | ||
154 | } | 154 | } |
@@ -157,7 +157,7 @@ namespace OpenSim.world | |||
157 | /// Remove a Agent's avatar | 157 | /// Remove a Agent's avatar |
158 | /// </summary> | 158 | /// </summary> |
159 | /// <param name="agentClient"></param> | 159 | /// <param name="agentClient"></param> |
160 | public virtual void RemoveViewerAgent(SimClient agentClient) | 160 | public virtual void RemoveViewerAgent(ClientView agentClient) |
161 | { | 161 | { |
162 | 162 | ||
163 | } | 163 | } |