Example #1
0
 public ClientView(TcpClient tcpClient, ServerView serverView)
 {
     Id     = Guid.NewGuid().ToString();
     client = tcpClient;
     server = serverView;
     serverView.AddConnection(this);
 }
Example #2
0
 public Settings(ServerView sv, string username, string ipAddr, string password, string port)
 {
     InitializeComponent();
     this.server_view = sv;
     ipAddrText.Text = ipAddr;
     passwordText.Text = password;
     portText.Text = port;
 }
Example #3
0
        internal ClientConnection(ServerView father, TcpClient textTcp, String password, ArrayList name)
        {
            this._father = father;
            this._textTcp = textTcp;
            ChallengeMessage auth = new ChallengeMessage();
            auth.salt = new Random().Next().ToString();
            auth.sendMe(textTcp.GetStream()); //mando il sale
            ResponseChallengeMessage respo = ResponseChallengeMessage.recvMe(textTcp.GetStream());

            if (name.Contains(respo.username))
            {
                //connessione fallita
                ConfigurationMessage fail = new ConfigurationMessage("Nome utente già utilizzato");
                fail.sendMe(textTcp.GetStream());
                throw new ClientConnectionFail("Un client ha fornito un nome utente già utilizzato");
            }
            this._username = respo.username;
            if (Pds2Util.createPswMD5(password, auth.salt).Equals(respo.pswMd5))
            {
                //creo le connessioni per i socket clipboard e video
                IPAddress localadd = ((IPEndPoint)textTcp.Client.LocalEndPoint).Address;
                TcpListener lvideo = new TcpListener(localadd, 0);
                lvideo.Start();
                IAsyncResult videores = lvideo.BeginAcceptTcpClient(null, null);
                TcpListener lclip = new TcpListener(localadd, 0);
                lclip.Start();
                IAsyncResult clipres = lclip.BeginAcceptTcpClient(null, null);
                int porta_video = ((IPEndPoint)lvideo.LocalEndpoint).Port;
                int clip_video = ((IPEndPoint)lclip.LocalEndpoint).Port;
                new ConfigurationMessage(porta_video, clip_video, "Benvenuto")
                    .sendMe(textTcp.GetStream());
                _clipTcp = lclip.EndAcceptTcpClient(clipres);
                _videoTcp = lvideo.EndAcceptTcpClient(videores);
                //now the client is connected
                _textReceiver = new Thread(_receiveText);
                _textReceiver.IsBackground = true;
                _textReceiver.Start();
                _clipReceiver = new Thread(_receiveClipboard);
                _clipReceiver.IsBackground = true;
                _clipReceiver.Start();
            }
            else
            {
                //connessione fallita
                ConfigurationMessage fail = new ConfigurationMessage("password sbagliata");
                fail.sendMe(textTcp.GetStream());
                throw new ClientConnectionFail("Un client ha fornito una password sbagliata");
            }
        }
Example #4
0
        static void Main(string[] args)
        {
            try
            {
                server = new ServerView();
                listenTask = new Task(server.Listen);
                listenTask.Start();
            }
            catch (Exception ex)
            {
                server.Disconnect();
                Console.WriteLine(ex.Message);
            }

            Console.ReadLine();
        }
Example #5
0
 public Settings(ServerView sv)
 {
     InitializeComponent();
     this.server_view = sv;
 }
Example #6
0
 public keyboard(ServerView s)
 {
     InitializeComponent();
     this.sv = s;
 }