aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/XferManager.cs
diff options
context:
space:
mode:
authorMW2007-08-28 14:21:17 +0000
committerMW2007-08-28 14:21:17 +0000
commit8e3b2392d129d727bfd00a2d9faa08d9e5be92de (patch)
tree7e6b89ee495af1d5ea76c58fc0796a3bb38ecc5d /OpenSim/Region/Environment/XferManager.cs
parentEnsure that UserProfileData doesn't pass down null values. (diff)
downloadopensim-SC-8e3b2392d129d727bfd00a2d9faa08d9e5be92de.zip
opensim-SC-8e3b2392d129d727bfd00a2d9faa08d9e5be92de.tar.gz
opensim-SC-8e3b2392d129d727bfd00a2d9faa08d9e5be92de.tar.bz2
opensim-SC-8e3b2392d129d727bfd00a2d9faa08d9e5be92de.tar.xz
Start of trying to make Region/Scene more modular.
Added preliminary IRegionModule interface. Also have a work in progress way of Modules registering optional API methods (kind of like Apache optional functions). But there must be a cleaner/nicer way in c# of doing these than the current way. Added three work in progress modules: ChatModule (simple handles in world chat, but by moving this to a module, we could support other types of chat modules, ie like a irc - opensim bridge module. ) , AvatarProfilesModule and XferModule. Moved most of the code from Scene.ModifyTerrain() into the BasicTerrain library, as the start of trying to make that more modular. Stopped Child agents showing up as part of the "show users" command.
Diffstat (limited to 'OpenSim/Region/Environment/XferManager.cs')
-rw-r--r--OpenSim/Region/Environment/XferManager.cs140
1 files changed, 0 insertions, 140 deletions
diff --git a/OpenSim/Region/Environment/XferManager.cs b/OpenSim/Region/Environment/XferManager.cs
deleted file mode 100644
index c49601c..0000000
--- a/OpenSim/Region/Environment/XferManager.cs
+++ /dev/null
@@ -1,140 +0,0 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5using libsecondlife;
6using OpenSim.Framework.Interfaces;
7using OpenSim.Framework.Utilities;
8
9namespace OpenSim.Region.Environment
10{
11 public class XferManager
12 {
13 public Dictionary<string, byte[]> NewFiles = new Dictionary<string, byte[]>();
14 public Dictionary<ulong, XferDownLoad> Transfers = new Dictionary<ulong, XferDownLoad>();
15
16 public XferManager()
17 {
18
19 }
20
21 /// <summary>
22 ///
23 /// </summary>
24 /// <param name="remoteClient"></param>
25 /// <param name="xferID"></param>
26 /// <param name="fileName"></param>
27 public void RequestXfer(IClientAPI remoteClient, ulong xferID, string fileName)
28 {
29 lock (NewFiles)
30 {
31 if (NewFiles.ContainsKey(fileName))
32 {
33 if (!Transfers.ContainsKey(xferID))
34 {
35 byte[] fileData = NewFiles[fileName];
36 XferDownLoad transaction = new XferDownLoad(fileName, fileData, xferID, remoteClient);
37 Transfers.Add(xferID, transaction);
38 NewFiles.Remove(fileName);
39 transaction.StartSend();
40 }
41 }
42 }
43 }
44
45 public void AckPacket(IClientAPI remoteClient, ulong xferID, uint packet)
46 {
47 if (this.Transfers.ContainsKey(xferID))
48 {
49 Transfers[xferID].AckPacket(packet);
50 }
51 }
52
53 public void AddNewFile(string fileName, byte[] data)
54 {
55 lock (NewFiles)
56 {
57 if (NewFiles.ContainsKey(fileName))
58 {
59 NewFiles[fileName] = data;
60 }
61 else
62 {
63 NewFiles.Add(fileName, data);
64 }
65 }
66 }
67
68 public class XferDownLoad
69 {
70 public byte[] Data = new byte[0];
71 public string FileName = "";
72 public ulong XferID = 0;
73 public int DataPointer = 0;
74 public uint Packet = 0;
75 public IClientAPI Client;
76 public uint Serial = 1;
77 private bool complete = false;
78
79 public XferDownLoad(string fileName, byte[] data, ulong xferID, IClientAPI client)
80 {
81 FileName = fileName;
82 Data = data;
83 XferID = xferID;
84 Client = client;
85 }
86
87 public XferDownLoad()
88 {
89
90 }
91
92 public void StartSend()
93 {
94 if (Data.Length < 1000)
95 {
96 // for now (testing ) we only support files under 1000 bytes
97 byte[] transferData = new byte[Data.Length + 4];
98 Array.Copy(Helpers.IntToBytes(Data.Length), 0, transferData, 0, 4);
99 Array.Copy(Data, 0, transferData, 4, Data.Length);
100 Client.SendXferPacket(XferID, 0 + 0x80000000, transferData);
101 complete = true;
102 }
103 else
104 {
105 byte[] transferData = new byte[1000 +4];
106 Array.Copy(Helpers.IntToBytes(Data.Length), 0, transferData, 0, 4);
107 Array.Copy(Data, 0, transferData, 4, 1000);
108 Client.SendXferPacket(XferID, 0 , transferData);
109 Packet++;
110 DataPointer = 1000;
111 }
112 }
113
114 public void AckPacket(uint packet)
115 {
116 if (!complete)
117 {
118 if ((Data.Length - DataPointer) > 1000)
119 {
120 byte[] transferData = new byte[1000];
121 Array.Copy(Data, DataPointer, transferData, 0, 1000);
122 Client.SendXferPacket(XferID, Packet, transferData);
123 Packet++;
124 DataPointer += 1000;
125 }
126 else
127 {
128 byte[] transferData = new byte[Data.Length - DataPointer];
129 Array.Copy(Data, DataPointer, transferData, 0, Data.Length - DataPointer);
130 uint endPacket = Packet |= (uint)0x80000000;
131 Client.SendXferPacket(XferID, endPacket, transferData);
132 Packet++;
133 DataPointer += (Data.Length - DataPointer);
134 complete = true;
135 }
136 }
137 }
138 }
139 }
140}