Beispiel #1
0
 public static void NetworkInitialize(List <Party> parties, bool isLocal = true)
 {
     if (isLocal)
     {
         Dictionary <PartyType, ReceiverLocal> partyReceicerMap = new Dictionary <PartyType, ReceiverLocal>();
         foreach (var party in parties)
         {
             ReceiverLocal receiver = new ReceiverLocal(parties, party);
             partyReceicerMap.Add(party.Type, receiver);
             party.AddReceiver(receiver);
             receiver.StartReceiver();
         }
         foreach (var party in parties)
         {
             SenderLocal sender = new SenderLocal(partyReceicerMap, party, parties);
             party.AddSender(sender);
             sender.StartSender();
         }
     }
     else
     {
         foreach (var party in parties)
         {
             ReceiverInternet receiver = new ReceiverInternet(Config.partyAddress, party);
             SenderInternet   sender   = new SenderInternet(Config.partyAddress, party, receiver);
             party.AddReceiver(receiver);
             party.AddSender(sender);
             receiver.StartReceiver();
             sender.StartSender();
         }
     }
 }
Beispiel #2
0
 // constructor
 public SenderInternet(Dictionary <PartyType, IPEndPoint> partyAddress, Party localParty, ReceiverInternet receiver)
     : base(localParty, receiver)
 {
     this.partyIPMap = partyAddress;
     foreach (var party in partyAddress.Keys)
     {
         if (party != localParty.Type)
         {
             msgBuffer.Add(party, new ConcurrentList());
             connectDone.Add(party, new ManualResetEvent(false));
             sendDone.Add(party, new ManualResetEvent(false));
         }
     }
     // client need to send EOP message to itself
     if (localParty.Type == PartyType.Client)
     {
         msgBuffer.Add(PartyType.Client, new ConcurrentList());
         connectDone.Add(PartyType.Client, new ManualResetEvent(false));
         sendDone.Add(PartyType.Client, new ManualResetEvent(false));
     }
 }