예제 #1
0
        private void pendingConnection_gotFileTransferId(object sender)
        {
            PendingViaConnection eventPvc = (PendingViaConnection)sender;

            Console.WriteLine("Pending Event! " + eventPvc.socket.RemoteEndPoint.ToString());
            int  i     = 0;
            bool found = false;

            for ( ; i < pendingViaConnections.Count && !found; i++)
            {
                PendingViaConnection pvc = (PendingViaConnection)pendingViaConnections[i];
                if (eventPvc.FileTransferId == pvc.FileTransferId)
                {
                    ViaConnection tempVia = new ViaConnection(pvc.socket, eventPvc.socket);
                    Console.WriteLine("Via Connection Established! \t" + eventPvc.socket.RemoteEndPoint.ToString() + '\t' + pvc.socket.RemoteEndPoint.ToString());
                    pendingViaConnections.RemoveAt(i);
                    found = true;
                }
            }
            if (found)
            {
                //	pendingViaConnections.RemoveAt(i);
            }
            else
            {
                pendingViaConnections.Add(eventPvc);
            }
        }
예제 #2
0
        private void ViaConnectionRecived(IAsyncResult ar)
        {
            try
            {
                PendingViaConnection pendingConnection = new PendingViaConnection(viaSocket.EndAccept(ar));
                pendingConnection.gotFileTransferId += new DGP_Messenger_Sever.PendingViaConnection.GotFileTransferId(pendingConnection_gotFileTransferId);
                Console.WriteLine("Via server Astablished From Ip: " + pendingConnection.socket.RemoteEndPoint.ToString());


                /*foreach(Client client in clientList)
                 * {
                 *      if(viaClient.Socket.RemoteEndPoint.ToString() == client.ClientSocket.RemoteEndPoint.ToString())
                 *      {
                 *              foreach(ViaClient via in viaClientList)
                 *              {
                 *                      if(via.DGPContactId == client.Id)
                 *                      {
                 *                              ViaClient viaClient = new ViaClient(client.socket, contact.socket);
                 *                              //via.DGPContactSocket = viaClient.Socket;
                 *                              Console.WriteLine("Two client connected!");
                 *                              found = true;
                 *                      }
                 *              }
                 *      }
                 * }
                 *
                 * if(found == false)
                 * {
                 *      viaClientList.Add(viaClient);
                 *      Console.WriteLine("New viaClient created!");
                 * }*/
                viaSocket.BeginAccept(new AsyncCallback(ViaConnectionRecived), this);
            }
            catch (ObjectDisposedException)
            {
            }
        }
예제 #3
0
        private void ViaConnectionRecived(IAsyncResult ar)
        {
            try
            {
                PendingViaConnection pendingConnection = new PendingViaConnection(viaSocket.EndAccept(ar));
                pendingConnection.gotFileTransferId += new DGP_Messenger_Sever.PendingViaConnection.GotFileTransferId(pendingConnection_gotFileTransferId);
                Console.WriteLine("Via server Astablished From Ip: " + pendingConnection.socket.RemoteEndPoint.ToString());

                /*foreach(Client client in clientList)
                {
                    if(viaClient.Socket.RemoteEndPoint.ToString() == client.ClientSocket.RemoteEndPoint.ToString())
                    {
                        foreach(ViaClient via in viaClientList)
                        {
                            if(via.DGPContactId == client.Id)
                            {
                                ViaClient viaClient = new ViaClient(client.socket, contact.socket);
                                //via.DGPContactSocket = viaClient.Socket;
                                Console.WriteLine("Two client connected!");
                                found = true;
                            }
                        }
                    }
                }

                if(found == false)
                {
                    viaClientList.Add(viaClient);
                    Console.WriteLine("New viaClient created!");
                }*/
                viaSocket.BeginAccept(new AsyncCallback(ViaConnectionRecived), this);
            }
            catch (ObjectDisposedException)
            {
            }
        }