Esempio n. 1
0
        private static void SendEncoded(object e, string mode)
        {
            string         encoded = JsonConvert.SerializeObject(e, Formatting.Indented);
            UDPMIDIMessage m       = new UDPMIDIMessage(mode, encoded);

            //LogOutMessage(encoded);
            foreach (UdpUser client in BroadcastClients)
            {
                client.Send(m.ToJson());
            }
        }
Esempio n. 2
0
        private static void Indevice_MessageReceived(IMidiMessage message)
        {
            string         encoded = JsonConvert.SerializeObject(message, Formatting.Indented);
            UDPMIDIMessage m       = new UDPMIDIMessage("message", encoded);

            //Console.WriteLine(m.ToJson());
            foreach (UdpUser client in BroadcastClients)
            {
                client.Send(m.ToJson());
            }
        }
Esempio n. 3
0
        private static void AddListenServerAddresses()
        {
            //throw new NotImplementedException();
            string ip       = "";
            int    port     = 32123;
            bool   complete = false;

            do
            {
                Console.WriteLine("{0} Listen Servers Found:\n", ListenClients.Count);

                for (int i = 0; i < ListenClients.Count; i++)
                {
                    Console.WriteLine("{0}:{1}", i, ListenClients[i].Hostname + ":" + ListenClients[i].Port.ToString());
                }

                Console.WriteLine("\nEnter Listen Server IP Address:\n (defaults to [127.0.0.1], q to quit) \n");
                Console.Write("?>");
                read = Console.ReadLine();
                if (read.ToLower().Equals("q"))
                {
                    complete = true;
                    break;
                }
                if (read == "")
                {
                    ip = "127.0.0.1";
                }
                else
                {
                    try
                    {
                        read = IPAddress.Parse(read).ToString();
                    }
                    catch (Exception ex)
                    {
                        ip = "127.0.0.1";
                    }
                }

                Console.WriteLine("Enter Listen Server Port:\n (defaults to [32123], q to quit) \n");
                Console.Write("?>");
                read = Console.ReadLine();
                if (read.ToLower().Equals("q"))
                {
                    complete = true;
                    break;
                }

                if (read == "")
                {
                    port = 32123;
                }
                else
                {
                    int.TryParse(read, out port);
                }
                Console.WriteLine("IP Address: {0}, Port: {1}\nOkay?\n<yes|no|quit>", ip, port);
                Console.Write("?>");
                read = Console.ReadLine();
                if (read.ToLower().Contains("q"))
                {
                    complete = true;
                    break;
                }
                if (read == "yes")
                {
                    UdpUser listen = UdpUser.ConnectTo(ip, port);
                    listen.Hostname = ip;
                    listen.Port     = port;
                    listen.Active   = false;
                    listen.Index    = ListenClients.Count;
                    UDPMIDIMessage m = new UDPMIDIMessage("subscribe", JsonConvert.SerializeObject(listen, typeof(UdpUser), null));
                    listen.Connect();
                    listen.Send(m.ToJson());
                    ListenClients.Add(listen);
                    read = "";
                }
                Console.WriteLine("Add more Listen Addresses?");
                Console.Write("?>");
                read = Console.ReadLine();
                if (read.ToLower().Equals("q"))
                {
                    complete = true;
                    break;
                }
                if (read.ToLower().Contains("no"))
                {
                    complete = true;
                    break;
                }
            } while (!complete);
        }