Exemplo n.º 1
0
        private static void ConnectToTcpServer()
        {
            var connected = false;

            while (!connected)
            {
                Console.WriteLine("Looking for server...");

                try
                {
                    Osprey.Locate("osprey.server")
                    .Stream("mango")
                    .Subscribe(msg => Console.WriteLine("MSG: " + msg.ToString()));

                    connected = true;
                }
                catch
                {
                    // ignored
                }

                Thread.Sleep(2000);
            }

            Console.WriteLine("Connected.");
        }
Exemplo n.º 2
0
        private static void StartSendingHttp()
        {
            Task.Factory.StartNew(async() =>
            {
                while (true)
                {
                    try
                    {
                        var task = Osprey.Locate("osprey.client")
                                   .Http()
                                   .Send(new HttpMessage <string, string>
                        {
                            Endpoint    = "test",
                            Payload     = "apples",
                            RequestType = HttpVerb.GET
                        });

                        var response = await task;

                        Console.WriteLine("RESPONSE: " + response);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }

                    Thread.Sleep(4000);
                }
            }, TaskCreationOptions.LongRunning);
        }