Exemplo n.º 1
0
        static void Main(string[] args)
        {
            IPEndPoint superPeerEndPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 8090);
            int port = 8091;

            ServerPeer server = new ServerPeer(superPeerEndPoint, port);
            server.Run();

            ClientPeer client = new ClientPeer(superPeerEndPoint);
            client.Run();

            //used Task.Factory.StartNew(() and sleep to simulate that this tasks are performed on different applications/machines
            Task.Factory.StartNew(() => server.AllowConnection(client.GetPeerAddress()));
            Thread.Sleep(3000);
            Task.Factory.StartNew(() => client.Connect(server.GetPeerAddress()));

            Thread.Sleep(3000);
            server.Send(new byte[] {1,2,3,4,5});
            Console.WriteLine(client.Read());

            client.Close();
            Thread.Sleep(1000);
            server.Close();

            Thread.Sleep(60000);
        }
Exemplo n.º 2
0
 public ServerPeerConnection(IPEndPoint superPeerEndPoint, MessageReceivedEvent onMessageReceivedEvent,
     ConnectionClosedEvent onConnectionClosedEvent)
     : base(new JsonSerializer())
 {
     MessageReceivedEvent = onMessageReceivedEvent;
     ConnectionClosedEvent = onConnectionClosedEvent;
     Peer = new ServerPeer(superPeerEndPoint, 0);   
 }        
 public TcpServerPeerConnection(ServerPeer serverPeer)
     : base(serverPeer)
 {           
 }
Exemplo n.º 4
0
 public ServerPeerConnection(ServerPeer serverPeer)
 {
     ServerPeer = serverPeer;
 }
 public TcpServerPeerConnection(ServerPeer serverPeer)
     : base(serverPeer)
 {
 }
Exemplo n.º 6
0
 public ServerPeerConnection(ServerPeer serverPeer)
 {
     ServerPeer = serverPeer;
  
 }