Exemplo n.º 1
0
        public void TestTcpMultiPartyNetworkSession()
        {
            Task <TcpMultiPartyNetworkSession> firstSessionTask  = TcpMultiPartyNetworkSession.EstablishAsync(FirstParty, IPAddress.Loopback, Port, 3);
            Task <TcpMultiPartyNetworkSession> secondSessionTask = TcpMultiPartyNetworkSession.EstablishAsync(SecondParty, IPAddress.Loopback, Port, 3);
            Task <TcpMultiPartyNetworkSession> thirdSessionTask  = TcpMultiPartyNetworkSession.EstablishAsync(ThirdParty, IPAddress.Loopback, Port, 3);

            TcpMultiPartyNetworkSession firstSession  = firstSessionTask.Result;
            TcpMultiPartyNetworkSession secondSession = secondSessionTask.Result;
            TcpMultiPartyNetworkSession thirdSession  = thirdSessionTask.Result;

            Assert.AreEqual(FirstParty, firstSession.LocalParty);
            Assert.AreEqual(SecondParty, secondSession.LocalParty);
            Assert.AreEqual(ThirdParty, thirdSession.LocalParty);

            CollectionAssert.AreEquivalent(new[] { SecondParty, ThirdParty }, firstSession.RemotePartySessions.Select(session => session.RemoteParty).ToArray());
            CollectionAssert.AreEquivalent(new[] { FirstParty, ThirdParty }, secondSession.RemotePartySessions.Select(session => session.RemoteParty).ToArray());
            CollectionAssert.AreEquivalent(new[] { FirstParty, SecondParty }, thirdSession.RemotePartySessions.Select(session => session.RemoteParty).ToArray());

            firstSessionTask.Dispose();
            secondSessionTask.Dispose();
            thirdSession.Dispose();
        }
Exemplo n.º 2
0
 public static IMultiPartyNetworkSession EstablishMultiParty(int localPartyId, int numberOfParties)
 {
     return(TcpMultiPartyNetworkSession.EstablishAsync(new Party(localPartyId), IPAddress.Loopback, Port, numberOfParties).Result);
 }
Exemplo n.º 3
0
 private static IMultiPartyNetworkSession CreateLocalSession(int localPartyId, int startPort, int numberOfParties)
 {
     return(TcpMultiPartyNetworkSession.EstablishAsync(new Party(localPartyId), IPAddress.Loopback, StartPort, NumberOfParties).Result);
 }