Exemple #1
0
        static async Task MainAsync(string[] args)
        {
            IO.Ably.DefaultLogger.LoggerSink = new MyLogger();
            DefaultLogger.LogLevel           = LogLevel.Debug;
            try
            {
                //Rest.Test().Wait();
                var client = Realtime.Test();
                client.Connect();
                var channel = client.Channels.Get("test");
                await channel.AttachAsync();

                DateTime start = DateTime.Now;
                while (true)
                {
                    channel.Publish(new Random().Next(1000000000, 1000000000).ToString(), new Random().Next(1000000000, 1000000000).ToString());
                    Thread.Sleep(1000);
                    Console.WriteLine("Connected time: " + (DateTime.Now - start).TotalSeconds + " seconds");
                }

                Console.ReadLine();
                ConsoleColor.Green.WriteLine("Success!");
            }
            catch (Exception ex)
            {
                ex.LogError();
            }
        }
Exemple #2
0
        static void Main(string[] args)
        {
            //IO.Ably.Logger.LoggerSink = new MyLogger();
            Logger.LogLevel = LogLevel.Debug;
            try
            {
                //Rest.Test().Wait();
                var client = Realtime.Test();
                client.Connect();
                var channel = client.Channels.Get("testchannel0");
                channel.Attach();
                channel.Presence.Subscribe(Presence_MessageReceived2);
                channel.Presence.EnterClientAsync("clientid1", "mydata");

                while (true)
                {
                    channel.Publish(new Random().Next(1000000000, 1000000000).ToString(), new Random().Next(1000000000, 1000000000).ToString());
                    Thread.Sleep(1000);
                    Console.WriteLine("Bytes used: " + GC.GetTotalMemory(true));
                }

                Console.ReadLine();
                ConsoleColor.Green.WriteLine("Success!");
            }
            catch (Exception ex)
            {
                ex.LogError();
            }
        }