-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathInformationPacket.cs
More file actions
55 lines (43 loc) · 1.26 KB
/
Copy pathInformationPacket.cs
File metadata and controls
55 lines (43 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using System;
using System.Collections.Generic;
namespace NTransit {
public class IpOffer {
public bool Accepted { get { return accepted; } }
public InformationPacket.PacketType Type { get { return ip.Type; } }
InformationPacket ip;
bool accepted;
public IpOffer(InformationPacket ip) {
this.ip = ip;
}
public InformationPacket Accept() {
accepted = true;
return ip;
}
}
public class InformationPacket {
public enum PacketType {
Data,
StartSequence,
EndSequence,
Auto
}
public Dictionary<string, object> Attributes;
public object Content { get; set; }
public PacketType Type { get; private set; }
public T ContentAs<T>() {
return (T)Content;
}
public InformationPacket(object content) : this(content, PacketType.Data) {}
public InformationPacket(object content, Dictionary<string, object> attributes) : this(content, PacketType.Data, attributes) {}
public InformationPacket(object content, PacketType type) {
Content = content;
Attributes = new Dictionary<string, object>();
Type = type;
}
public InformationPacket(object content, PacketType type, Dictionary<string, object> attributes) : this(content, type) {
foreach (var kvp in attributes) {
Attributes[kvp.Key] = kvp.Value;
}
}
}
}