diff options
Some more code refactoring, plus a restructuring of the directories so that the Grid servers can be a separate solution to the region server.
Diffstat (limited to 'OpenSim-Source/OpenSim.RegionServer/PacketServer.cs')
-rw-r--r-- | OpenSim-Source/OpenSim.RegionServer/PacketServer.cs | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/OpenSim-Source/OpenSim.RegionServer/PacketServer.cs b/OpenSim-Source/OpenSim.RegionServer/PacketServer.cs new file mode 100644 index 0000000..fb35723 --- /dev/null +++ b/OpenSim-Source/OpenSim.RegionServer/PacketServer.cs | |||
@@ -0,0 +1,89 @@ | |||
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, ClientView> ClientThreads = new Dictionary<uint, ClientView>(); | ||
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 virtual void ClientInPacket(uint circuitCode, Packet packet) | ||
30 | { | ||
31 | if (this.ClientThreads.ContainsKey(circuitCode)) | ||
32 | { | ||
33 | ClientThreads[circuitCode].InPacket(packet); | ||
34 | } | ||
35 | } | ||
36 | |||
37 | public virtual bool AddNewCircuitCodeClient(uint circuitCode) | ||
38 | { | ||
39 | return false; | ||
40 | } | ||
41 | |||
42 | public virtual void SendPacketToAllClients(Packet packet) | ||
43 | { | ||
44 | |||
45 | } | ||
46 | |||
47 | public virtual void SendPacketToAllExcept(Packet packet, ClientView simClient) | ||
48 | { | ||
49 | |||
50 | } | ||
51 | |||
52 | public virtual void AddClientPacketHandler(PacketType packetType, PacketMethod handler) | ||
53 | { | ||
54 | |||
55 | } | ||
56 | |||
57 | public virtual void RegisterClientPacketHandlers() | ||
58 | { | ||
59 | if (this._localWorld != null) | ||
60 | { | ||
61 | //ClientView.AddPacketHandler(PacketType.DeRezObject, _localWorld.DeRezObject); | ||
62 | ClientView.AddPacketHandler(PacketType.UUIDNameRequest, this.RequestUUIDName); | ||
63 | } | ||
64 | } | ||
65 | |||
66 | #region Client Packet Handlers | ||
67 | |||
68 | public bool RequestUUIDName(ClientView simClient, Packet packet) | ||
69 | { | ||
70 | System.Text.Encoding enc = System.Text.Encoding.ASCII; | ||
71 | Console.WriteLine(packet.ToString()); | ||
72 | UUIDNameRequestPacket nameRequest = (UUIDNameRequestPacket)packet; | ||
73 | UUIDNameReplyPacket nameReply = new UUIDNameReplyPacket(); | ||
74 | nameReply.UUIDNameBlock = new UUIDNameReplyPacket.UUIDNameBlockBlock[nameRequest.UUIDNameBlock.Length]; | ||
75 | |||
76 | for (int i = 0; i < nameRequest.UUIDNameBlock.Length; i++) | ||
77 | { | ||
78 | nameReply.UUIDNameBlock[i] = new UUIDNameReplyPacket.UUIDNameBlockBlock(); | ||
79 | nameReply.UUIDNameBlock[i].ID = nameRequest.UUIDNameBlock[i].ID; | ||
80 | nameReply.UUIDNameBlock[i].FirstName = enc.GetBytes("Who\0"); //for now send any name | ||
81 | nameReply.UUIDNameBlock[i].LastName = enc.GetBytes("Knows\0"); //in future need to look it up | ||
82 | } | ||
83 | simClient.OutPacket(nameReply); | ||
84 | return true; | ||
85 | } | ||
86 | |||
87 | #endregion | ||
88 | } | ||
89 | } | ||