Ejemplo n.º 1
0
        public static bool Connect()
        {
            if (ImageComparisonServer != null)
            {
                return(true);
            }

            try
            {
                ImageComparisonServer = new TcpClient();
                ImageComparisonServer.Connect(ParadoxImageServerHost, ParadoxImageServerPort);

                // Send initial parameters
                var networkStream = ImageComparisonServer.GetStream();
                var binaryWriter  = new BinaryWriter(networkStream);
                ImageTestResultConnection.Write(binaryWriter);

                return(true);
            }
            catch (Exception)
            {
                ImageComparisonServer = null;

                return(false);
            }
        }
Ejemplo n.º 2
0
        public static async Task <bool> ConnectAsync()
        {
            if (imageComparisonServer != null)
            {
                return(true);
            }

            try
            {
                imageComparisonServer = new StreamSocket();
                await imageComparisonServer.ConnectAsync(new HostName(ParadoxImageServerHost), ParadoxImageServerPort.ToString());

                // Send initial parameters
                using (var memoryStream = new MemoryStream())
                {
                    var binaryWriter = new BinaryWriter(memoryStream);
                    ImageTestResultConnection.Write(binaryWriter);

                    var dataWriter = new DataWriter(imageComparisonServer.OutputStream);
                    dataWriter.WriteBytes(memoryStream.ToArray());
                    await dataWriter.StoreAsync();

                    await dataWriter.FlushAsync();

                    dataWriter.DetachStream();
                }

                return(true);
            }
            catch (Exception)
            {
                imageComparisonServer = null;

                return(false);
            }
        }