Esempio n. 1
0
        private static void EstablishConnectionToMaster(String ip, int port, bool tls, List <Bundle> bundles)
        {
            int       protocolVersion = 1;
            TcpClient tcpClient       = new TcpClient(ip, port);

            streamWriter = new RSANetworkStreamWriter(tcpClient.GetStream());
            streamReader = new RSANetworkStreamReader(tcpClient.GetStream());
            ((RSANetworkStreamWriter)streamWriter).RSASubmit();

            /*if (!tls)
             * {
             *  streamWriter = new NetworkStreamWriter(tcpClient.GetStream());
             *  streamReader = new NetworkStreamReader(tcpClient.GetStream());
             * }*/
            streamWriter.Write(BitConverter.GetBytes(protocolVersion));
            streamWriter.Write(Encoding.UTF8.GetBytes("*****@*****.**"));
            streamWriter.Write(Encoding.UTF8.GetBytes("1231231"));
            streamWriter.Write(Encoding.UTF8.GetBytes("rig1"));
            streamWriter.Write(Encoding.UTF8.GetBytes("hashed1"));
            List <String> bundleNames = new List <string>();

            foreach (Bundle bundle in bundles)
            {
                bundleNames.Add(bundle.Name);
            }
            streamWriter.Write(Encoding.UTF8.GetBytes(String.Join(",", bundleNames)));
            streamWriter.Flush();
        }