Exemplo n.º 1
0
        public void Connect()
        {
            string address = OscHost;
            int    port    = OscPort ?? throw new ArgumentException("OscPort Must have a value");

            Client = new EosWeb.Core.OSC.OscClient(address, port);
            Client.ConnectAsync();
            Connected = true;
            Client.SendAsync("/eos/subscribe=1");
        }
Exemplo n.º 2
0
        static async Task Main(string[] args)
        {
            Hub hub = Hub.Default;

            Console.WriteLine("Publish: 1");
            hub.Publish <int>(1);
            await hub.PublishAsync <int>(2).ConfigureAwait(true);

            Console.WriteLine("Connecting....");



            // TCP server address
            string address = "172.16.32.225";

            if (args.Length > 0)
            {
                address = args[0];
            }

            // TCP server port
            int port = 3032;

            if (args.Length > 1)
            {
                port = int.Parse(args[1]);
            }

            Console.WriteLine($"TCP server address: {address}");
            Console.WriteLine($"TCP server port: {port}");

            Console.WriteLine();

            // Create a new TCP chat client
            using (var client = new Core.OSC.OscClient(address, port))
            {
                // Connect the client
                Console.Write("Client connecting...");
                client.ConnectAsync();
                Console.WriteLine("Done!");

                Console.WriteLine("Press Enter to stop the client or '!' to reconnect the client...");

                // Perform text input
                for (; ;)
                {
                    string line = Console.ReadLine();

                    if (string.IsNullOrWhiteSpace(line))
                    {
                        line = "/eos/ping";
                    }

                    // Disconnect the client
                    if (line == "!")
                    {
                        Console.Write("Client disconnecting...");
                        client.DisconnectAsync();
                        Console.WriteLine("Done!");
                        //continue;
                        break;
                    }

                    Bespoke.Osc.OscMessage message = new Bespoke.Osc.OscMessage(null, line, null);
                    var messagebytes = message.ToByteArray();
                    // Send the entered text to the chat server

                    var packetbytes = OscPacket.ValueToByteArray(messagebytes);
                    await hub.PublishAsync(message).ConfigureAwait(false);

                    client.SendAsync(packetbytes);
                }

                // Disconnect the client
                Console.Write("Client disconnecting...");
                client.DisconnectAndStop();
            }
            Console.WriteLine("Done!");
        }