diff options
Diffstat (limited to 'OpenSim/Region/Environment/Modules/VoiceChat/VoicePacketHeader.cs')
-rw-r--r-- | OpenSim/Region/Environment/Modules/VoiceChat/VoicePacketHeader.cs | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/OpenSim/Region/Environment/Modules/VoiceChat/VoicePacketHeader.cs b/OpenSim/Region/Environment/Modules/VoiceChat/VoicePacketHeader.cs new file mode 100644 index 0000000..2f9ec55 --- /dev/null +++ b/OpenSim/Region/Environment/Modules/VoiceChat/VoicePacketHeader.cs | |||
@@ -0,0 +1,38 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | |||
5 | namespace OpenSim.Region.Environment.Modules.VoiceChat | ||
6 | { | ||
7 | public class VoicePacketHeader | ||
8 | { | ||
9 | public byte type; | ||
10 | public int length; | ||
11 | |||
12 | public void Parse(byte[] data) | ||
13 | { | ||
14 | int offset = 0; | ||
15 | type = data[offset++]; | ||
16 | |||
17 | length = data[offset++]; | ||
18 | length |= data[offset++] << 8; | ||
19 | length |= data[offset++] << 16; | ||
20 | length |= data[offset++] << 24; | ||
21 | } | ||
22 | |||
23 | public void CopyTo(byte[] data, int offset) | ||
24 | { | ||
25 | data[offset + 0] = type; | ||
26 | |||
27 | data[offset + 1] = (byte)(length & 0x000000FF); | ||
28 | data[offset + 2] = (byte)((length & 0x0000FF00) >> 8); | ||
29 | data[offset + 3] = (byte)((length & 0x00FF0000) >> 16); | ||
30 | data[offset + 4] = (byte)((length & 0xFF000000) >> 24); | ||
31 | } | ||
32 | |||
33 | public int GetLength() | ||
34 | { | ||
35 | return 5; | ||
36 | } | ||
37 | } | ||
38 | } | ||