Example #1
0
 private static void Get()
 {
     Console.WriteLine("Get Data Packet");
     _objClient.Request <BinaryDataResponse>(new GetBinaryDataRequest(), e => {
         Console.WriteLine("Get Next Data Packet");
         Get();
     });
 }
Example #2
0
        private static void Main(string[] args)
        {
            //Initialize using the default config
            Config.Initialize();

            //When a message is received, display it on the console
            ReceiveOnChannelRequestAction.ChannelMessageReceived += delegate(string pChannel, string pMessage)
            {
                Console.WriteLine($"{pChannel} > {pMessage}");
            };

            //Establish a connection and subscribe to the "MyChannel"
            _objClient            = new Mitto.Client();
            _objClient.Connected += delegate(object sender, Mitto.Client pClient)
            {
                Console.WriteLine("Client Connected");
                _objClient.Request <ACKResponse>(
                    new ChannelSubscribe("MyChannel"), r =>
                {
                    if (r.Status.State == ResponseState.Success)
                    {
                        Start();
                    }
                    else
                    {
                        Console.WriteLine("Failed Subscribing to Channel");
                    }
                }
                    );
            };
            _objClient.ConnectAsync(new ClientParams()
            {
                Hostname = "localhost",
                Port     = 8080,
                Secure   = false
            });

            Console.CancelKeyPress += delegate(object sender, ConsoleCancelEventArgs e)
            {
                _quit.Set();
            };
            _quit.WaitOne();
        }
Example #3
0
 private static void Start()
 {
     ThreadPool.QueueUserWorkItem(s =>
     {
         while (true)
         {
             var text = Console.ReadLine();
             _objClient.Request <ACKResponse>(
                 new SendToChannelRequest("MyChannel", text),
                 r =>
             {
                 if (r.Status.State != ResponseState.Success)
                 {
                     Console.WriteLine($"Failed Sending: {text}");
                 }
             }
                 );
         }
     });
 }