protected virtual void Announce(MemBlock b, ISender from)
{
//When Subscribe or unsubscribe are called,
//they make copies of the ArrayList, thus we
//only need to hold the sync while we are
//getting the list of handlers.
/*
* Note that getting from Hashtable is threadsafe, multiple
* threads writing is a problem
*/
MemBlock payload = null;
int handlers = 0;
MultiSource ns = null;
PType t = null;
try {
t = PType.Parse(b, out payload);
ns = (MultiSource)DemuxHandler.GetTypeSource(t);
handlers = ns.Announce(payload, from);
/**
* @todo if no one handled the packet, we might want to send some
* ICMP-like message.
*/
if( handlers == 0 ) {
string p_s = payload.GetString(System.Text.Encoding.ASCII);
ProtocolLog.WriteIf(ProtocolLog.Exceptions, String.Format(
"No Handler for packet type: {0} from: {2}\n{1} :: {3}", t, p_s, from, b.ToBase16String()));
}
}
catch(Exception x) {
ProtocolLog.WriteIf(ProtocolLog.Exceptions, String.Format(
"Packet Handling Exception"));
string nodeSource = "null";
if (ns != null) {
nodeSource = ns.ToString();
}
ProtocolLog.WriteIf(ProtocolLog.Exceptions, String.Format(
"Handler: {0}\tEdge: {1}", nodeSource, from));
ProtocolLog.WriteIf(ProtocolLog.Exceptions, String.Format(
"Exception: {0}", x));
}
}
/**