diff options
author | MW | 2007-04-01 12:02:44 +0000 |
---|---|---|
committer | MW | 2007-04-01 12:02:44 +0000 |
commit | f0a3edfb34580334a2b8c8ebced8ee380ec733d7 (patch) | |
tree | e839080d14b2bd7aa69769c0e0dc6e9287671154 /OpenSim.RegionServer/SimClient.cs | |
parent | More work on adding Packets handlers and tested the first handler. (diff) | |
download | opensim-SC-f0a3edfb34580334a2b8c8ebced8ee380ec733d7.zip opensim-SC-f0a3edfb34580334a2b8c8ebced8ee380ec733d7.tar.gz opensim-SC-f0a3edfb34580334a2b8c8ebced8ee380ec733d7.tar.bz2 opensim-SC-f0a3edfb34580334a2b8c8ebced8ee380ec733d7.tar.xz |
Moved more packet types to handlers
Diffstat (limited to 'OpenSim.RegionServer/SimClient.cs')
-rw-r--r-- | OpenSim.RegionServer/SimClient.cs | 176 |
1 files changed, 69 insertions, 107 deletions
diff --git a/OpenSim.RegionServer/SimClient.cs b/OpenSim.RegionServer/SimClient.cs index 5bc5e43..e9bfd56 100644 --- a/OpenSim.RegionServer/SimClient.cs +++ b/OpenSim.RegionServer/SimClient.cs | |||
@@ -123,7 +123,8 @@ namespace OpenSim | |||
123 | 123 | ||
124 | protected virtual void RegisterLocalPacketHandlers() | 124 | protected virtual void RegisterLocalPacketHandlers() |
125 | { | 125 | { |
126 | 126 | this.AddLocalPacketHandler(PacketType.LogoutRequest, this.Logout); | |
127 | this.AddLocalPacketHandler(PacketType.AgentCachedTexture, this.AgentTextureCached); | ||
127 | } | 128 | } |
128 | 129 | ||
129 | public static bool AddPacketHandler(PacketType packetType, PacketMethod handler) | 130 | public static bool AddPacketHandler(PacketType packetType, PacketMethod handler) |
@@ -250,24 +251,6 @@ namespace OpenSim | |||
250 | // Console.WriteLine(appear.ToString()); | 251 | // Console.WriteLine(appear.ToString()); |
251 | this.ClientAvatar.SetAppearance(appear); | 252 | this.ClientAvatar.SetAppearance(appear); |
252 | break; | 253 | break; |
253 | case PacketType.AgentCachedTexture: | ||
254 | Console.WriteLine(Pack.ToString()); | ||
255 | AgentCachedTexturePacket chechedtex = (AgentCachedTexturePacket)Pack; | ||
256 | AgentCachedTextureResponsePacket cachedresp = new AgentCachedTextureResponsePacket(); | ||
257 | cachedresp.AgentData.AgentID = this.AgentID; | ||
258 | cachedresp.AgentData.SessionID = this.SessionID; | ||
259 | cachedresp.AgentData.SerialNum = this.cachedtextureserial; | ||
260 | this.cachedtextureserial++; | ||
261 | cachedresp.WearableData = new AgentCachedTextureResponsePacket.WearableDataBlock[chechedtex.WearableData.Length]; | ||
262 | for (int i = 0; i < chechedtex.WearableData.Length; i++) | ||
263 | { | ||
264 | cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock(); | ||
265 | cachedresp.WearableData[i].TextureIndex = chechedtex.WearableData[i].TextureIndex; | ||
266 | cachedresp.WearableData[i].TextureID = LLUUID.Zero; | ||
267 | cachedresp.WearableData[i].HostName = new byte[0]; | ||
268 | } | ||
269 | this.OutPacket(cachedresp); | ||
270 | break; | ||
271 | case PacketType.ObjectAdd: | 254 | case PacketType.ObjectAdd: |
272 | m_world.AddNewPrim((ObjectAddPacket)Pack, this); | 255 | m_world.AddNewPrim((ObjectAddPacket)Pack, this); |
273 | break; | 256 | break; |
@@ -292,7 +275,6 @@ namespace OpenSim | |||
292 | break; | 275 | break; |
293 | case PacketType.MultipleObjectUpdate: | 276 | case PacketType.MultipleObjectUpdate: |
294 | MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket)Pack; | 277 | MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket)Pack; |
295 | |||
296 | for (int i = 0; i < multipleupdate.ObjectData.Length; i++) | 278 | for (int i = 0; i < multipleupdate.ObjectData.Length; i++) |
297 | { | 279 | { |
298 | if (multipleupdate.ObjectData[i].Type == 9) //change position | 280 | if (multipleupdate.ObjectData[i].Type == 9) //change position |
@@ -306,7 +288,6 @@ namespace OpenSim | |||
306 | 288 | ||
307 | } | 289 | } |
308 | } | 290 | } |
309 | |||
310 | //should update stored position of the prim | 291 | //should update stored position of the prim |
311 | } | 292 | } |
312 | else if (multipleupdate.ObjectData[i].Type == 10)//rotation | 293 | else if (multipleupdate.ObjectData[i].Type == 10)//rotation |
@@ -350,63 +331,6 @@ namespace OpenSim | |||
350 | case PacketType.AgentUpdate: | 331 | case PacketType.AgentUpdate: |
351 | ClientAvatar.HandleUpdate((AgentUpdatePacket)Pack); | 332 | ClientAvatar.HandleUpdate((AgentUpdatePacket)Pack); |
352 | break; | 333 | break; |
353 | case PacketType.LogoutRequest: | ||
354 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("OpenSimClient.cs:ProcessInPacket() - Got a logout request"); | ||
355 | //send reply to let the client logout | ||
356 | LogoutReplyPacket logReply = new LogoutReplyPacket(); | ||
357 | logReply.AgentData.AgentID = this.AgentID; | ||
358 | logReply.AgentData.SessionID = this.SessionID; | ||
359 | logReply.InventoryData = new LogoutReplyPacket.InventoryDataBlock[1]; | ||
360 | logReply.InventoryData[0] = new LogoutReplyPacket.InventoryDataBlock(); | ||
361 | logReply.InventoryData[0].ItemID = LLUUID.Zero; | ||
362 | OutPacket(logReply); | ||
363 | //tell all clients to kill our object | ||
364 | KillObjectPacket kill = new KillObjectPacket(); | ||
365 | kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1]; | ||
366 | kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock(); | ||
367 | kill.ObjectData[0].ID = this.ClientAvatar.localid; | ||
368 | foreach (SimClient client in m_clientThreads.Values) | ||
369 | { | ||
370 | client.OutPacket(kill); | ||
371 | } | ||
372 | if (this.m_userServer != null) | ||
373 | { | ||
374 | this.m_inventoryCache.ClientLeaving(this.AgentID, this.m_userServer); | ||
375 | } | ||
376 | else | ||
377 | { | ||
378 | this.m_inventoryCache.ClientLeaving(this.AgentID, null); | ||
379 | } | ||
380 | |||
381 | m_gridServer.LogoutSession(this.SessionID, this.AgentID, this.CircuitCode); | ||
382 | lock (m_world.Entities) | ||
383 | { | ||
384 | m_world.Entities.Remove(this.AgentID); | ||
385 | } | ||
386 | //need to do other cleaning up here too | ||
387 | m_clientThreads.Remove(this.CircuitCode); //this.userEP); | ||
388 | m_application.RemoveClientCircuit(this.CircuitCode); | ||
389 | this.ClientThread.Abort(); | ||
390 | break; | ||
391 | case PacketType.ChatFromViewer: | ||
392 | ChatFromViewerPacket inchatpack = (ChatFromViewerPacket)Pack; | ||
393 | if (Helpers.FieldToString(inchatpack.ChatData.Message) == "") break; | ||
394 | |||
395 | |||
396 | libsecondlife.Packets.ChatFromSimulatorPacket reply = new ChatFromSimulatorPacket(); | ||
397 | reply.ChatData.Audible = 1; | ||
398 | reply.ChatData.Message = inchatpack.ChatData.Message; | ||
399 | reply.ChatData.ChatType = 1; | ||
400 | reply.ChatData.SourceType = 1; | ||
401 | reply.ChatData.Position = this.ClientAvatar.position; | ||
402 | reply.ChatData.FromName = _enc.GetBytes(this.ClientAvatar.firstname + " " + this.ClientAvatar.lastname + "\0"); | ||
403 | reply.ChatData.OwnerID = this.AgentID; | ||
404 | reply.ChatData.SourceID = this.AgentID; | ||
405 | foreach (SimClient client in m_clientThreads.Values) | ||
406 | { | ||
407 | client.OutPacket(reply); | ||
408 | } | ||
409 | break; | ||
410 | case PacketType.ObjectImage: | 334 | case PacketType.ObjectImage: |
411 | ObjectImagePacket imagePack = (ObjectImagePacket)Pack; | 335 | ObjectImagePacket imagePack = (ObjectImagePacket)Pack; |
412 | for (int i = 0; i < imagePack.ObjectData.Length; i++) | 336 | for (int i = 0; i < imagePack.ObjectData.Length; i++) |
@@ -429,23 +353,12 @@ namespace OpenSim | |||
429 | ((OpenSim.world.Primitive)ent).UpdateObjectFlags(flags); | 353 | ((OpenSim.world.Primitive)ent).UpdateObjectFlags(flags); |
430 | } | 354 | } |
431 | } | 355 | } |
432 | |||
433 | break; | 356 | break; |
434 | case PacketType.AssetUploadRequest: | 357 | case PacketType.AssetUploadRequest: |
435 | //this.debug = true; | ||
436 | AssetUploadRequestPacket request = (AssetUploadRequestPacket)Pack; | 358 | AssetUploadRequestPacket request = (AssetUploadRequestPacket)Pack; |
437 | // Console.WriteLine(Pack.ToString()); | ||
438 | // if (request.AssetBlock.Type == 0) | ||
439 | // { | ||
440 | //this.UploadAssets.HandleUploadPacket(request, LLUUID.Random()); | ||
441 | //} | ||
442 | //else | ||
443 | //{ | ||
444 | this.UploadAssets.HandleUploadPacket(request, request.AssetBlock.TransactionID.Combine(this.SecureSessionID)); | 359 | this.UploadAssets.HandleUploadPacket(request, request.AssetBlock.TransactionID.Combine(this.SecureSessionID)); |
445 | //} | ||
446 | break; | 360 | break; |
447 | case PacketType.SendXferPacket: | 361 | case PacketType.SendXferPacket: |
448 | Console.WriteLine(Pack.ToString()); | ||
449 | this.UploadAssets.HandleXferPacket((SendXferPacketPacket)Pack); | 362 | this.UploadAssets.HandleXferPacket((SendXferPacketPacket)Pack); |
450 | break; | 363 | break; |
451 | case PacketType.CreateInventoryFolder: | 364 | case PacketType.CreateInventoryFolder: |
@@ -522,11 +435,11 @@ namespace OpenSim | |||
522 | break; | 435 | break; |
523 | case PacketType.DeRezObject: | 436 | case PacketType.DeRezObject: |
524 | //OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Received DeRezObject packet"); | 437 | //OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Received DeRezObject packet"); |
525 | m_world.DeRezObject((DeRezObjectPacket)Pack, this); | 438 | m_world.DeRezObject(this, Pack); |
526 | break; | 439 | break; |
527 | case PacketType.RezObject: | 440 | case PacketType.RezObject: |
528 | //Console.WriteLine(Pack.ToString()); | 441 | //Console.WriteLine(Pack.ToString()); |
529 | m_world.RezObject(this, (RezObjectPacket)Pack); | 442 | m_world.RezObject(this, Pack); |
530 | break; | 443 | break; |
531 | case PacketType.RequestTaskInventory: | 444 | case PacketType.RequestTaskInventory: |
532 | // Console.WriteLine(Pack.ToString()); | 445 | // Console.WriteLine(Pack.ToString()); |
@@ -548,22 +461,6 @@ namespace OpenSim | |||
548 | this.OutPacket(replytask); | 461 | this.OutPacket(replytask); |
549 | } | 462 | } |
550 | break; | 463 | break; |
551 | case PacketType.UUIDNameRequest: | ||
552 | //System.Text.Encoding _enc = System.Text.Encoding.ASCII; | ||
553 | Console.WriteLine(Pack.ToString()); | ||
554 | UUIDNameRequestPacket nameRequest = (UUIDNameRequestPacket)Pack; | ||
555 | UUIDNameReplyPacket nameReply = new UUIDNameReplyPacket(); | ||
556 | nameReply.UUIDNameBlock = new UUIDNameReplyPacket.UUIDNameBlockBlock[nameRequest.UUIDNameBlock.Length]; | ||
557 | |||
558 | for (int i = 0; i < nameRequest.UUIDNameBlock.Length; i++) | ||
559 | { | ||
560 | nameReply.UUIDNameBlock[i] = new UUIDNameReplyPacket.UUIDNameBlockBlock(); | ||
561 | nameReply.UUIDNameBlock[i].ID = nameRequest.UUIDNameBlock[i].ID; | ||
562 | nameReply.UUIDNameBlock[i].FirstName = _enc.GetBytes("Who\0"); //for now send any name | ||
563 | nameReply.UUIDNameBlock[i].LastName = _enc.GetBytes("Knows\0"); //in future need to look it up | ||
564 | } | ||
565 | this.OutPacket(nameReply); | ||
566 | break; | ||
567 | case PacketType.AgentAnimation: | 464 | case PacketType.AgentAnimation: |
568 | //Console.WriteLine(Pack.ToString()); | 465 | //Console.WriteLine(Pack.ToString()); |
569 | break; | 466 | break; |
@@ -872,6 +769,71 @@ namespace OpenSim | |||
872 | ClientLoop(); | 769 | ClientLoop(); |
873 | } | 770 | } |
874 | } | 771 | } |
772 | #region Packet handlers | ||
773 | |||
774 | protected virtual bool Logout(SimClient simClient, Packet packet) | ||
775 | { | ||
776 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("OpenSimClient.cs:ProcessInPacket() - Got a logout request"); | ||
777 | //send reply to let the client logout | ||
778 | LogoutReplyPacket logReply = new LogoutReplyPacket(); | ||
779 | logReply.AgentData.AgentID = this.AgentID; | ||
780 | logReply.AgentData.SessionID = this.SessionID; | ||
781 | logReply.InventoryData = new LogoutReplyPacket.InventoryDataBlock[1]; | ||
782 | logReply.InventoryData[0] = new LogoutReplyPacket.InventoryDataBlock(); | ||
783 | logReply.InventoryData[0].ItemID = LLUUID.Zero; | ||
784 | OutPacket(logReply); | ||
785 | //tell all clients to kill our object | ||
786 | KillObjectPacket kill = new KillObjectPacket(); | ||
787 | kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1]; | ||
788 | kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock(); | ||
789 | kill.ObjectData[0].ID = this.ClientAvatar.localid; | ||
790 | foreach (SimClient client in m_clientThreads.Values) | ||
791 | { | ||
792 | client.OutPacket(kill); | ||
793 | } | ||
794 | if (this.m_userServer != null) | ||
795 | { | ||
796 | this.m_inventoryCache.ClientLeaving(this.AgentID, this.m_userServer); | ||
797 | } | ||
798 | else | ||
799 | { | ||
800 | this.m_inventoryCache.ClientLeaving(this.AgentID, null); | ||
801 | } | ||
802 | |||
803 | m_gridServer.LogoutSession(this.SessionID, this.AgentID, this.CircuitCode); | ||
804 | lock (m_world.Entities) | ||
805 | { | ||
806 | m_world.Entities.Remove(this.AgentID); | ||
807 | } | ||
808 | //need to do other cleaning up here too | ||
809 | m_clientThreads.Remove(this.CircuitCode); //this.userEP); | ||
810 | m_application.RemoveClientCircuit(this.CircuitCode); | ||
811 | this.ClientThread.Abort(); | ||
812 | return true; | ||
813 | } | ||
814 | |||
815 | protected bool AgentTextureCached(SimClient simclient, Packet packet) | ||
816 | { | ||
817 | Console.WriteLine(packet.ToString()); | ||
818 | AgentCachedTexturePacket chechedtex = (AgentCachedTexturePacket)packet; | ||
819 | AgentCachedTextureResponsePacket cachedresp = new AgentCachedTextureResponsePacket(); | ||
820 | cachedresp.AgentData.AgentID = this.AgentID; | ||
821 | cachedresp.AgentData.SessionID = this.SessionID; | ||
822 | cachedresp.AgentData.SerialNum = this.cachedtextureserial; | ||
823 | this.cachedtextureserial++; | ||
824 | cachedresp.WearableData = new AgentCachedTextureResponsePacket.WearableDataBlock[chechedtex.WearableData.Length]; | ||
825 | for (int i = 0; i < chechedtex.WearableData.Length; i++) | ||
826 | { | ||
827 | cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock(); | ||
828 | cachedresp.WearableData[i].TextureIndex = chechedtex.WearableData[i].TextureIndex; | ||
829 | cachedresp.WearableData[i].TextureID = LLUUID.Zero; | ||
830 | cachedresp.WearableData[i].HostName = new byte[0]; | ||
831 | } | ||
832 | this.OutPacket(cachedresp); | ||
833 | return true; | ||
834 | } | ||
835 | |||
836 | #endregion | ||
875 | 837 | ||
876 | private AgentInventory CreateInventory(LLUUID baseFolder) | 838 | private AgentInventory CreateInventory(LLUUID baseFolder) |
877 | { | 839 | { |