aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/OpenSim.RegionServer/PacketServer.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/OpenSim.RegionServer/PacketServer.cs88
1 files changed, 88 insertions, 0 deletions
diff --git a/OpenSim/OpenSim.RegionServer/PacketServer.cs b/OpenSim/OpenSim.RegionServer/PacketServer.cs
new file mode 100644
index 0000000..9c8f65c
--- /dev/null
+++ b/OpenSim/OpenSim.RegionServer/PacketServer.cs
@@ -0,0 +1,88 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using OpenSim.world;
5using libsecondlife.Packets;
6
7namespace 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.UUIDNameRequest, this.RequestUUIDName);
62 }
63 }
64
65 #region Client Packet Handlers
66
67 public bool RequestUUIDName(ClientView simClient, Packet packet)
68 {
69 System.Text.Encoding enc = System.Text.Encoding.ASCII;
70 Console.WriteLine(packet.ToString());
71 UUIDNameRequestPacket nameRequest = (UUIDNameRequestPacket)packet;
72 UUIDNameReplyPacket nameReply = new UUIDNameReplyPacket();
73 nameReply.UUIDNameBlock = new UUIDNameReplyPacket.UUIDNameBlockBlock[nameRequest.UUIDNameBlock.Length];
74
75 for (int i = 0; i < nameRequest.UUIDNameBlock.Length; i++)
76 {
77 nameReply.UUIDNameBlock[i] = new UUIDNameReplyPacket.UUIDNameBlockBlock();
78 nameReply.UUIDNameBlock[i].ID = nameRequest.UUIDNameBlock[i].ID;
79 nameReply.UUIDNameBlock[i].FirstName = enc.GetBytes("Who\0"); //for now send any name
80 nameReply.UUIDNameBlock[i].LastName = enc.GetBytes("Knows\0"); //in future need to look it up
81 }
82 simClient.OutPacket(nameReply);
83 return true;
84 }
85
86 #endregion
87 }
88}