diff options
author | MW | 2007-08-22 14:47:01 +0000 |
---|---|---|
committer | MW | 2007-08-22 14:47:01 +0000 |
commit | f02ebb6476eeef56f2b790d6b7f472fb84c5fa69 (patch) | |
tree | f15bdc0b5fabb9e282feeea9548a1c59329fb6b1 /OpenSim/Region | |
parent | Start of Task Inventory (ie prim's inventory). For now, you can only move scr... (diff) | |
download | opensim-SC-f02ebb6476eeef56f2b790d6b7f472fb84c5fa69.zip opensim-SC-f02ebb6476eeef56f2b790d6b7f472fb84c5fa69.tar.gz opensim-SC-f02ebb6476eeef56f2b790d6b7f472fb84c5fa69.tar.bz2 opensim-SC-f02ebb6476eeef56f2b790d6b7f472fb84c5fa69.tar.xz |
Added forgotten file.
Made a change to the Scene.EventManager OnRezScript event, it now includes the itemID as a param. This uuid is unique to each instance of a script, so can be used for tracking changes/editing, stopping and deleting a script.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/Environment/Scenes/Scene.Inventory.cs | 4 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/SceneEvents.cs | 6 | ||||
-rw-r--r-- | OpenSim/Region/Environment/XferManagaer.cs | 142 |
3 files changed, 147 insertions, 5 deletions
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs index bf7bb7e..fa1b865 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs | |||
@@ -229,7 +229,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
229 | { | 229 | { |
230 | string script = Util.FieldToString(rezAsset.Data); | 230 | string script = Util.FieldToString(rezAsset.Data); |
231 | //Console.WriteLine("rez script "+script); | 231 | //Console.WriteLine("rez script "+script); |
232 | this.EventManager.TriggerRezScript(localID, script); | 232 | this.EventManager.TriggerRezScript(localID, itemID, script); |
233 | rezzed = true; | 233 | rezzed = true; |
234 | } | 234 | } |
235 | else | 235 | else |
@@ -240,7 +240,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
240 | { | 240 | { |
241 | string script = Util.FieldToString(rezAsset.Data); | 241 | string script = Util.FieldToString(rezAsset.Data); |
242 | // Console.WriteLine("rez script " + script); | 242 | // Console.WriteLine("rez script " + script); |
243 | this.EventManager.TriggerRezScript(localID, script); | 243 | this.EventManager.TriggerRezScript(localID, itemID, script); |
244 | rezzed = true; | 244 | rezzed = true; |
245 | } | 245 | } |
246 | } | 246 | } |
diff --git a/OpenSim/Region/Environment/Scenes/SceneEvents.cs b/OpenSim/Region/Environment/Scenes/SceneEvents.cs index 89aeda6..09a7f21 100644 --- a/OpenSim/Region/Environment/Scenes/SceneEvents.cs +++ b/OpenSim/Region/Environment/Scenes/SceneEvents.cs | |||
@@ -37,7 +37,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
37 | public event ObjectGrabDelegate OnObjectGrab; | 37 | public event ObjectGrabDelegate OnObjectGrab; |
38 | public event OnPermissionErrorDelegate OnPermissionError; | 38 | public event OnPermissionErrorDelegate OnPermissionError; |
39 | 39 | ||
40 | public delegate void NewRezScript(uint localID, string script); | 40 | public delegate void NewRezScript(uint localID, LLUUID itemID, string script); |
41 | public event NewRezScript OnRezScript; | 41 | public event NewRezScript OnRezScript; |
42 | 42 | ||
43 | 43 | ||
@@ -110,11 +110,11 @@ namespace OpenSim.Region.Environment.Scenes | |||
110 | OnObjectGrab(localID, offsetPos, remoteClient); | 110 | OnObjectGrab(localID, offsetPos, remoteClient); |
111 | } | 111 | } |
112 | 112 | ||
113 | public void TriggerRezScript(uint localID, string script) | 113 | public void TriggerRezScript(uint localID, LLUUID itemID, string script) |
114 | { | 114 | { |
115 | if (OnRezScript != null) | 115 | if (OnRezScript != null) |
116 | { | 116 | { |
117 | OnRezScript(localID, script); | 117 | OnRezScript(localID, itemID, script); |
118 | } | 118 | } |
119 | } | 119 | } |
120 | } | 120 | } |
diff --git a/OpenSim/Region/Environment/XferManagaer.cs b/OpenSim/Region/Environment/XferManagaer.cs new file mode 100644 index 0000000..30fbaf0 --- /dev/null +++ b/OpenSim/Region/Environment/XferManagaer.cs | |||
@@ -0,0 +1,142 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | |||
5 | using libsecondlife; | ||
6 | using OpenSim.Framework.Interfaces; | ||
7 | using OpenSim.Framework.Utilities; | ||
8 | |||
9 | namespace OpenSim.Region.Environment | ||
10 | { | ||
11 | public class XferManagaer | ||
12 | { | ||
13 | public Dictionary<string, byte[]> NewFiles = new Dictionary<string, byte[]>(); | ||
14 | public Dictionary<ulong, XferDownLoad> Transfers = new Dictionary<ulong, XferDownLoad>(); | ||
15 | |||
16 | public XferManagaer() | ||
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 | Console.WriteLine("xfer request for " + fileName); | ||
30 | lock (NewFiles) | ||
31 | { | ||
32 | if (NewFiles.ContainsKey(fileName)) | ||
33 | { | ||
34 | if (!Transfers.ContainsKey(xferID)) | ||
35 | { | ||
36 | byte[] fileData = NewFiles[fileName]; | ||
37 | XferDownLoad transaction = new XferDownLoad(fileName, fileData, xferID, remoteClient); | ||
38 | Transfers.Add(xferID, transaction); | ||
39 | NewFiles.Remove(fileName); | ||
40 | transaction.StartSend(); | ||
41 | } | ||
42 | } | ||
43 | } | ||
44 | } | ||
45 | |||
46 | public void AckPacket(IClientAPI remoteClient, ulong xferID, uint packet) | ||
47 | { | ||
48 | if (this.Transfers.ContainsKey(xferID)) | ||
49 | { | ||
50 | Transfers[xferID].AckPacket(packet); | ||
51 | } | ||
52 | } | ||
53 | |||
54 | public void AddNewFile(string fileName, byte[] data) | ||
55 | { | ||
56 | lock (NewFiles) | ||
57 | { | ||
58 | if (NewFiles.ContainsKey(fileName)) | ||
59 | { | ||
60 | NewFiles[fileName] = data; | ||
61 | } | ||
62 | else | ||
63 | { | ||
64 | NewFiles.Add(fileName, data); | ||
65 | } | ||
66 | } | ||
67 | } | ||
68 | |||
69 | public class XferDownLoad | ||
70 | { | ||
71 | public byte[] Data = new byte[0]; | ||
72 | public string FileName = ""; | ||
73 | public ulong XferID = 0; | ||
74 | public int DataPointer = 0; | ||
75 | public uint Packet = 0; | ||
76 | public IClientAPI Client; | ||
77 | public uint Serial = 1; | ||
78 | private bool complete = false; | ||
79 | |||
80 | public XferDownLoad(string fileName, byte[] data, ulong xferID, IClientAPI client) | ||
81 | { | ||
82 | FileName = fileName; | ||
83 | Data = data; | ||
84 | XferID = xferID; | ||
85 | Client = client; | ||
86 | } | ||
87 | |||
88 | public XferDownLoad() | ||
89 | { | ||
90 | |||
91 | } | ||
92 | |||
93 | public void StartSend() | ||
94 | { | ||
95 | if (Data.Length < 1000) | ||
96 | { | ||
97 | // for now (testing ) we only support files under 1000 bytes | ||
98 | byte[] transferData = new byte[Data.Length + 4]; | ||
99 | Array.Copy(Helpers.IntToBytes(Data.Length), 0, transferData, 0, 4); | ||
100 | Array.Copy(Data, 0, transferData, 4, Data.Length); | ||
101 | Client.SendXferPacket(XferID, 0 + 0x80000000, transferData); | ||
102 | complete = true; | ||
103 | Console.WriteLine("xfer is under 1000 bytes"); | ||
104 | } | ||
105 | else | ||
106 | { | ||
107 | byte[] transferData = new byte[1000 +4]; | ||
108 | Array.Copy(Helpers.IntToBytes(Data.Length), 0, transferData, 0, 4); | ||
109 | Array.Copy(Data, 0, transferData, 4, 1000); | ||
110 | Client.SendXferPacket(XferID, 0 , transferData); | ||
111 | Packet++; | ||
112 | DataPointer = 1000; | ||
113 | } | ||
114 | } | ||
115 | |||
116 | public void AckPacket(uint packet) | ||
117 | { | ||
118 | if (!complete) | ||
119 | { | ||
120 | if ((Data.Length - DataPointer) > 1000) | ||
121 | { | ||
122 | byte[] transferData = new byte[1000]; | ||
123 | Array.Copy(Data, DataPointer, transferData, 0, 1000); | ||
124 | Client.SendXferPacket(XferID, Packet, transferData); | ||
125 | Packet++; | ||
126 | DataPointer += 1000; | ||
127 | } | ||
128 | else | ||
129 | { | ||
130 | byte[] transferData = new byte[Data.Length - DataPointer]; | ||
131 | Array.Copy(Data, DataPointer, transferData, 0, Data.Length - DataPointer); | ||
132 | uint endPacket = Packet |= (uint)0x80000000; | ||
133 | Client.SendXferPacket(XferID, endPacket, transferData); | ||
134 | Packet++; | ||
135 | DataPointer += (Data.Length - DataPointer); | ||
136 | complete = true; | ||
137 | } | ||
138 | } | ||
139 | } | ||
140 | } | ||
141 | } | ||
142 | } | ||