Exemple #1
0
        static void Main(string[] args)
        {
            var hostname = args[0];
            var port     = Int32.Parse(args[1]);

            var blyncClient       = new BlyncClient();
            var tcpClientSettings = new TcpClientSettings
            {
                ConnectionTimeoutPeriod = 30000,
                Hostname            = hostname,
                Port                = port,
                PacketStreamFactory = new JsonPacketStreamFactory()
            };

            if (blyncClient.NumberOfDevices == 0)
            {
                Console.WriteLine("No devices found");
                return;
            }

            Console.WriteLine("Devices found: {0}", blyncClient.NumberOfDevices);
            for (int id = 0; id < blyncClient.NumberOfDevices; id++)
            {
                Console.WriteLine("    [{0}] {1}", id, blyncClient.GetDeviceType(id));
            }


            Console.WriteLine("Connecting to {0}:{1}", hostname, port);

            new Application(blyncClient, tcpClientSettings).Run();
        }
Exemple #2
0
        private BlyncTcpClient.OnConnectedEvent SendIdentityOnConnectedEvent()
        {
            return((sender, eventArgs) =>
            {
                Console.WriteLine("Connected");

                var devices = new List <Device>();
                for (int i = 0; i < _blyncClient.NumberOfDevices; i++)
                {
                    devices.Add(new Device {
                        DeviceId = i, DeviceType = _blyncClient.GetDeviceType(i).ToString()
                    });
                }

                var status = new JsonIdentityPacket
                {
                    Name = Environment.MachineName,
                    Devices = devices
                };

                var protocol = new JsonProtocol();

                var json = protocol.Serialize(status);
                var packet = protocol.SetPacketContents(0, json);

                _blyncTcpClient.Send(packet, new CancellationToken()).Wait();
            });
        }
Exemple #3
0
        public void DisplayConnectedDevices(BlyncClient client)
        {
            Console.WriteLine("Number of devices connected: {0}", client.NumberOfDevices);

            for (var deviceId = 0; deviceId < client.NumberOfDevices; deviceId++)
            {
                Console.WriteLine("Device ID: {0}, Device Type: {1}", deviceId, client.GetDeviceType(deviceId));
            }
        }
Exemple #4
0
 private void Then_I_should_get_a_list_of_all_device_types_connected()
 {
     Assert.That(_blyncClient.GetDeviceTypes().Count(), Is.GreaterThan(0));
     Assert.That((int)_blyncClient.GetDeviceType(0), Is.GreaterThan(0));
 }
Exemple #5
0
 private TestDelegate When_I_access_a_device_type()
 {
     return(() => _blyncClient.GetDeviceType(0));
 }