本文整理汇总了C#中Brunet.Transport.TransportAddress类的典型用法代码示例。如果您正苦于以下问题:C# TransportAddress类的具体用法?C# TransportAddress怎么用?C# TransportAddress使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TransportAddress类属于Brunet.Transport命名空间,在下文中一共展示了TransportAddress类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetEdgeListenerList
/// <summary>Retrieve a given EL Dictionary for the TA Type. This could leak,
/// though that would take the creation of many different EL types and in normal
/// usage there will only be 1 or 2 types.</summary>
static protected Dictionary<int, SimulationEdgeListener> GetEdgeListenerList(TransportAddress.TAType type)
{
if(!_el_map.ContainsKey(type)) {
_el_map[type] = new Dictionary<int, SimulationEdgeListener>();
}
return _el_map[type];
}
示例2: Authorize
public override TAAuthorizer.Decision Authorize(TransportAddress a) {
if (_denied_id == ((SimulationTransportAddress)a).ID) {
return TAAuthorizer.Decision.Deny;
} else {
//else this decision should not matter
return TAAuthorizer.Decision.None;
}
}
示例3: UpdateTAs
public void UpdateTAs(TransportAddress remote_ta, TransportAddress local_ta)
{
if(_known_tas.Length == 2) {
return;
}
_known_tas = new TransportAddress[2] { _internal_ta[0], local_ta };
_allow_inbound = true;
}
示例4: XmppEdge
/// <summary>Create a XmppEdge.</summary>
public XmppEdge(IEdgeSendHandler send_handler, XmppTransportAddress local_ta,
XmppTransportAddress remote_ta, bool inbound) :
base(send_handler, inbound)
{
_ip = new IdentifierPair();
_local_ta = local_ta;
_remote_ta = remote_ta;
To = remote_ta.JID;
}
示例5: SubringEdge
/// <summary>Constructor for an outgoing edge, since we don't know the remote
/// id yet, it must be outgoing!</summary>
public SubringEdge(TransportAddress local_ta, TransportAddress remote_ta,
bool inbound, ISender sender, PType ptype) :
base(null, inbound)
{
_ip = new IdentifierPair();
_local_ta = local_ta;
_remote_ta = remote_ta;
_ptype = ptype;
_overlay_sender = sender;
}
示例6: ConeNat
public ConeNat(TransportAddress ta, int timeout)
{
_external_ta = new TransportAddress[1] { ta };
_internal_ta = new TransportAddress[1] { ((SimulationTransportAddress) ta).Invert() };
_known_tas = _internal_ta;
// TBC uses a staged GC, so values are still in after one timeout
_allowed = new TimeBasedCache<TransportAddress, bool>(timeout / 2);
_allowed.EvictionHandler += HandleEviction;
_allow_inbound = false;
}
示例7: SimulationEdge
public SimulationEdge(IEdgeSendHandler s, int local_id, int remote_id,
bool is_in, int delay, TransportAddress.TAType type) : base(s, is_in)
{
Delay = delay;
LocalID = local_id;
RemoteID = remote_id;
_ta_type = type;
_local_ta = GetTransportAddress(local_id);
_remote_ta = GetTransportAddress(remote_id);
SimEL = s as SimulationEdgeListener;
}
示例8: CreateEdgeTo
/**
* This creates Edges of a given type
*/
public void CreateEdgeTo(TransportAddress destination,
EdgeListener.EdgeCreationCallback ecb)
{
TransportAddress.TAType t = destination.TransportAddressType;
if( _el_map.Contains( t ) ) {
EdgeListener el = (EdgeListener)_el_map[ t ];
el.CreateEdgeTo( destination, ecb );
}
else {
ecb(false, null, new EdgeException("No EdgeListener for TA type: " +
t.ToString() ) );
}
}
示例9: SubringEdgeListener
/// <summary>Create a SubringEdgeListener.</summary>
/// <param name="shared_node">The overlay used for the transport.</param>
/// <param name="private_node">The overlay needing edges.</param>
public SubringEdgeListener(Node shared_node, Node private_node)
{
_shared_node = shared_node;
_private_node = private_node;
_it = new IdentifierTable();
_local_ta = new SubringTransportAddress(shared_node.Address as AHAddress,
shared_node.Realm);
_ptype = new PType("ns:" + shared_node.Realm);
shared_node.DemuxHandler.GetTypeSource(_ptype).Subscribe(this, null);
_running = 0;
_started = 0;
}
示例10: Authorize
public override TAAuthorizer.Decision Authorize(TransportAddress a)
{
int id = ((SimulationTransportAddress) a).ID;
if(id == 0) {
return TAAuthorizer.Decision.Allow;
}
if(!_allowed.Contains(id)) {
if(Rand.NextDouble() > Prob) {
_allowed[id] = TAAuthorizer.Decision.Allow;
} else {
_allowed[id] = TAAuthorizer.Decision.Deny;
}
}
return (TAAuthorizer.Decision) _allowed[id];
}
示例11: CreateEdgeTo
public override void CreateEdgeTo(TransportAddress ta, EdgeCreationCallback ecb)
{
SubringTransportAddress sta = ta as SubringTransportAddress;
if(sta == null) {
ecb(false, null, new Exception("TA Type is not Subring!"));
} else if(!sta.Namespace.Equals(_shared_node.Realm)) {
ecb(false, null, new Exception("Namespace mismatch"));
} else if(sta.Target.Equals(_private_node.Address)) {
ecb(false, null, new Exception("You are me!"));
} else {
SubringEdge se = new SubringEdge(_local_ta, sta, false,
new AHExactSender(_shared_node, sta.Target), _ptype);
se.CloseEvent += CloseHandler;
_it.Add(se);
ecb(true, se, null);
}
}
示例12: Test
public void Test()
{
SimulationTransportAddress.Enable();
SimulationTransportAddressOther.Enable();
var ta = TransportAddressFactory.CreateInstance("b.s://234580") as SimulationTransportAddress;
var tai = ta.Invert();
TransportAddress[] tas = new TransportAddress[2] { tai, ta };
var ta_oth = TransportAddressFactory.CreateInstance("b.s://234581");
var ta_oth0 = TransportAddressFactory.CreateInstance("b.s://234582");
var nat = new RestrictedConeNat(ta, 30000);
Assert.IsFalse(nat.Incoming(ta_oth), "No outbound yet...");
Assert.IsTrue(nat.Outgoing(ta_oth), "outbound...");
Assert.IsFalse(nat.AllowingIncomingConnections, "Have not received external ta.");
Assert.AreEqual(nat.InternalTransportAddresses, nat.KnownTransportAddresses, "ITA and KTA match");
nat.UpdateTAs(ta_oth, ta);
Assert.IsTrue(nat.Incoming(ta_oth), "Allowed incoming");
Assert.IsFalse(nat.Incoming(ta_oth0), "Port mapped systems must send out a packet first...");
Assert.IsTrue(nat.AllowingIncomingConnections, "Have received external ta.");
Assert.AreEqual(tas, nat.KnownTransportAddresses, "Two TAs!");
Assert.IsTrue(nat.Outgoing(ta_oth0), "outbound...");
Brunet.Util.SimpleTimer.RunSteps(7500);
Assert.IsTrue(nat.Incoming(ta_oth0), "Allowed incoming 0");
Brunet.Util.SimpleTimer.RunSteps(7500);
Assert.IsTrue(nat.Incoming(ta_oth0), "Allowed incoming 0");
Brunet.Util.SimpleTimer.RunSteps(7500);
Assert.IsTrue(nat.Incoming(ta_oth0), "Allowed incoming 0");
Brunet.Util.SimpleTimer.RunSteps(7500);
Assert.IsTrue(nat.Incoming(ta_oth0), "Allowed incoming 0");
Assert.IsTrue(nat.AllowingIncomingConnections, "Have received external ta.");
Assert.AreEqual(tas, nat.KnownTransportAddresses, "Two TAs!");
Brunet.Util.SimpleTimer.RunSteps(60000);
Assert.IsFalse(nat.AllowingIncomingConnections, "AllowIC: Timed out...");
Assert.IsFalse(nat.Incoming(ta_oth), "Incoming: Timed out....");
}
示例13: IPTransportAddress
public IPTransportAddress(TransportAddress.TAType t, IPAddress addr, int port):
this(String.Format("brunet.{0}://{1}:{2}", TATypeToString(t), addr, port))
{
_type = t;
_ips = new ArrayList(1);
_ips.Add( addr );
}
示例14: Outgoing
public bool Outgoing(TransportAddress remote_ta)
{
return true;
}
示例15: PublicNat
public PublicNat(TransportAddress local_ta)
{
_local_tas = new TransportAddress[1] { local_ta };
}