diff options
author | MW | 2007-04-01 20:42:42 +0000 |
---|---|---|
committer | MW | 2007-04-01 20:42:42 +0000 |
commit | f48aabd1b163fcb19d49748dc2f0c33aa277b091 (patch) | |
tree | 0fbe919b1cafbf7c2795443f64c470ecbc0aad10 /OpenSim.RegionServer/PacketServer.cs | |
parent | More cleaning up of SimClient and packet handling (diff) | |
download | opensim-SC-f48aabd1b163fcb19d49748dc2f0c33aa277b091.zip opensim-SC-f48aabd1b163fcb19d49748dc2f0c33aa277b091.tar.gz opensim-SC-f48aabd1b163fcb19d49748dc2f0c33aa277b091.tar.bz2 opensim-SC-f48aabd1b163fcb19d49748dc2f0c33aa277b091.tar.xz |
More refactoring
Diffstat (limited to '')
-rw-r--r-- | OpenSim.RegionServer/PacketServer.cs | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/OpenSim.RegionServer/PacketServer.cs b/OpenSim.RegionServer/PacketServer.cs new file mode 100644 index 0000000..af0382c --- /dev/null +++ b/OpenSim.RegionServer/PacketServer.cs | |||
@@ -0,0 +1,74 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using OpenSim.world; | ||
5 | using libsecondlife.Packets; | ||
6 | |||
7 | namespace OpenSim | ||
8 | { | ||
9 | public class PacketServer | ||
10 | { | ||
11 | private OpenSimNetworkHandler _networkHandler; | ||
12 | private World _localWorld; | ||
13 | public Dictionary<uint, SimClient> ClientThreads = new Dictionary<uint, SimClient>(); | ||
14 | |||
15 | public PacketServer(OpenSimNetworkHandler networkHandler) | ||
16 | { | ||
17 | _networkHandler = networkHandler; | ||
18 | _networkHandler.RegisterPacketServer(this); | ||
19 | } | ||
20 | |||
21 | public World LocalWorld | ||
22 | { | ||
23 | set | ||
24 | { | ||
25 | this._localWorld = value; | ||
26 | } | ||
27 | } | ||
28 | |||
29 | public void ClientInPacket(uint circuitCode, Packet packet) | ||
30 | { | ||
31 | if (this.ClientThreads.ContainsKey(circuitCode)) | ||
32 | { | ||
33 | ClientThreads[circuitCode].InPacket(packet); | ||
34 | } | ||
35 | } | ||
36 | |||
37 | public bool AddNewCircuitCodeClient(uint circuitCode) | ||
38 | { | ||
39 | return false; | ||
40 | } | ||
41 | |||
42 | public virtual void RegisterClientPacketHandlers() | ||
43 | { | ||
44 | SimClient.AddPacketHandler(PacketType.ModifyLand, _localWorld.ModifyTerrain); | ||
45 | SimClient.AddPacketHandler(PacketType.ChatFromViewer, _localWorld.SimChat); | ||
46 | SimClient.AddPacketHandler(PacketType.RezObject, _localWorld.RezObject); | ||
47 | SimClient.AddPacketHandler(PacketType.DeRezObject, _localWorld.DeRezObject); | ||
48 | SimClient.AddPacketHandler(PacketType.UUIDNameRequest, this.RequestUUIDName); | ||
49 | } | ||
50 | |||
51 | #region Client Packet Handlers | ||
52 | |||
53 | public bool RequestUUIDName(SimClient simClient, Packet packet) | ||
54 | { | ||
55 | System.Text.Encoding enc = System.Text.Encoding.ASCII; | ||
56 | Console.WriteLine(packet.ToString()); | ||
57 | UUIDNameRequestPacket nameRequest = (UUIDNameRequestPacket)packet; | ||
58 | UUIDNameReplyPacket nameReply = new UUIDNameReplyPacket(); | ||
59 | nameReply.UUIDNameBlock = new UUIDNameReplyPacket.UUIDNameBlockBlock[nameRequest.UUIDNameBlock.Length]; | ||
60 | |||
61 | for (int i = 0; i < nameRequest.UUIDNameBlock.Length; i++) | ||
62 | { | ||
63 | nameReply.UUIDNameBlock[i] = new UUIDNameReplyPacket.UUIDNameBlockBlock(); | ||
64 | nameReply.UUIDNameBlock[i].ID = nameRequest.UUIDNameBlock[i].ID; | ||
65 | nameReply.UUIDNameBlock[i].FirstName = enc.GetBytes("Who\0"); //for now send any name | ||
66 | nameReply.UUIDNameBlock[i].LastName = enc.GetBytes("Knows\0"); //in future need to look it up | ||
67 | } | ||
68 | simClient.OutPacket(nameReply); | ||
69 | return true; | ||
70 | } | ||
71 | |||
72 | #endregion | ||
73 | } | ||
74 | } | ||