Exemplo n.º 1
0
        public TcpServerController(TcpListener server, TraceSource trace, ClientStore clientStore, NetworkStreamReader reader, NetworkStreamWriter writer)
        {
            if (server == null)
            {
                throw new ArgumentNullException(nameof(server));
            }
            if (trace == null)
            {
                throw new ArgumentNullException(nameof(trace));
            }
            if (clientStore == null)
            {
                throw new ArgumentNullException(nameof(clientStore));
            }
            if (reader == null)
            {
                throw new ArgumentNullException(nameof(reader));
            }
            if (writer == null)
            {
                throw new ArgumentNullException(nameof(writer));
            }

            _server      = server;
            _trace       = trace;
            _clientStore = clientStore;
            _reader      = reader;
            _writer      = writer;
        }
        public TcpClientController(TraceSource trace, string ip, int port, NetworkStreamReader reader, NetworkStreamWriter writer)
        {
            if (trace == null)
            {
                throw new ArgumentNullException(nameof(trace));
            }
            if (string.IsNullOrWhiteSpace(ip))
            {
                throw new ArgumentNullException(nameof(ip));
            }
            if (reader == null)
            {
                throw new ArgumentNullException(nameof(reader));
            }
            if (writer == null)
            {
                throw new ArgumentNullException(nameof(writer));
            }

            _trace  = trace;
            _ip     = ip;
            _port   = port;
            _reader = reader;
            _writer = writer;
        }
Exemplo n.º 3
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();
        }