当前位置: 首页>>代码示例>>C#>>正文


C# Client.Queue方法代码示例

本文整理汇总了C#中Client.Queue方法的典型用法代码示例。如果您正苦于以下问题:C# Client.Queue方法的具体用法?C# Client.Queue怎么用?C# Client.Queue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Client的用法示例。


在下文中一共展示了Client.Queue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        static void Main(string[] args)
        {
            var configCheck = new ConfigurationWrapper();
            string yourProjectId = ""; // enter your projectid here or use app.config
            string yourtoken = ""; // enter your token or use app.config

            if (String.IsNullOrEmpty(yourProjectId))
            {
                yourProjectId = configCheck.BlacksmithProjectId;
            }

            if (String.IsNullOrEmpty(yourtoken))
            {
                yourtoken = configCheck.BlacksmithToken;
            }

            var client = new Client(yourProjectId, yourtoken);

            var pusher = new Timer { AutoReset = true, Interval = 1000, Enabled = true };
            var one = new Timer { AutoReset = true, Interval = 2500, Enabled = true };
            var bunch = new Timer { AutoReset = true, Interval = 5000, Enabled = true };

            // let's start pushing messages into the queue
            // the queue name is based on the class name
            pusher.Elapsed += (sender, eventArgs) =>
                client
                    .Queue<MyMessage>()
                    .Push(new MyMessage { Text = string.Format("Hello, World from {0}!", ++_count) });

            // I will handle try catches for you for
            // when it comes to deserializing and executing your processing code
            // also, I will delete the message from the queue on success!
            one.Elapsed +=
                (sender, eventArgs) =>
                client.Queue<MyMessage>()
                    .Next()
                    .OnError(Console.WriteLine)
                    .Consume((m, ctx) =>
                    {
                        Console.WriteLine("consuming one: {0}", m.Target.Text);
                    });

            // Can't wait, get a bunch of messages back and consume each one
            bunch.Elapsed +=
                (sender, eventArgs) =>
                    client.Queue<MyMessage>()
                        .Get(5)
                        .ForEach(r => r.Consume((m, ctx) =>
                        {
                            Console.WriteLine("{0} : {1}", m.Id, m.Target.Text);
                        }));

            Console.ReadLine();

            // clear the queue
            pusher.Stop();
            bunch.Stop();

            client.Queue<MyMessage>().Clear();
        }
开发者ID:khalidabuhakmeh,项目名称:blacksmith,代码行数:60,代码来源:Program.cs

示例2: Main

        static void Main(string[] args)
        {
            var myIp = GetExternalIp();
            Client client = new Client(
                "520a3b7de68cce0009000005",
                "QgYqrjF8oIVFv_G8UsZOQcLjDBA");
            var queue = client.Queue("GigaSimpleChat");
            Console.WriteLine("Enter messages to be sent to the IronMQ server:");
            while (true)
            {
                Message msg = queue.Get();
                if (msg != null)
                {
                    Console.WriteLine(msg.Body);
                    //Thread.Sleep(100);
                    //queue.DeleteMessage(msg);
                }

                Thread.Sleep(100);
                while (Console.KeyAvailable)
                {
                    string message = Console.ReadLine();
                    queue.Push(myIp + " : " + message);
                    Console.WriteLine("Message sent to the IronMQ server.");
                }
            }
        }
开发者ID:sabrie,项目名称:TelerikAcademy,代码行数:27,代码来源:SimpleChat.cs

示例3: All

        public IQueryable<string> All(string username)
        {
            Client client = new Client(MessageQueueProjectId, MessageQueueToken);
            Queue queue = client.Queue(MessageQueueName);

            var currentUser = this.usersRepository
                .All()
                .FirstOrDefault(u => u.UserName == username);

            List<string> messages = new List<string>();
            Message msg = queue.Get();

            while (msg != null)
            {
                string messageContent = msg.Body;
                if (!messageContent.StartsWith(currentUser.Nickname))
                {
                    messages.Add(messageContent);
                    queue.DeleteMessage(msg);
                }

                msg = queue.Get();
            }

            return messages.AsQueryable();
        }
开发者ID:DimitarDKirov,项目名称:Forum-Paulo-Coelho,代码行数:26,代码来源:NotificationService.cs

示例4: Connect

 public override void Connect()
 {
     this.client = new Client("564b5fdc9195a800070000e7", "mRhNH5sVa9jcitAm5nEX");
     this.queue = client.Queue("chat");
     this.shutdown = false;
     this.receiver = Task.Factory.StartNew(this.Receive);
 }
开发者ID:iovigi,项目名称:Telerik-Academy,代码行数:7,代码来源:IronMQClient.cs

示例5: IronMQReceiver

 static IronMQReceiver()
 {
     string projectId = ConfigurationManager.AppSettings["IRON_MQ_PROJECT_ID"];
     var token = ConfigurationManager.AppSettings["IRON_MQ_TOKEN"];
     var client = new Client(projectId, token);
     queue = client.Queue("IronMQChat");
 }
开发者ID:vic-alexiev,项目名称:CloudServices,代码行数:7,代码来源:IronMQReceiver.cs

示例6: Main

        static void Main(string[] args)
        {
            var myIp = GetInternalIP();
            if(myIp == "No IP")
            {
                myIp = GetInternalIP();
            }

            Client client = new Client(
                "5648e1b79195a800070000a0",
                "H5thSqUOWRX1KVID3Yc3");
            var queue = client.Queue("SimpleChat");
            Console.WriteLine("Enter messages to be sent to the IronMQ server:");
            while (true)
            {
                Message msg = queue.Get();
                if (msg != null)
                {
                    Console.WriteLine(msg.Body);
                    //Thread.Sleep(100);
                    //queue.DeleteMessage(msg);
                }

                Thread.Sleep(1000);
                while (Console.KeyAvailable)
                {
                    string message = Console.ReadLine();
                    queue.Push(myIp + " : " + message);
                    Console.WriteLine("Message sent to the IronMQ server.");
                }
            }
        }
开发者ID:NikitoG,项目名称:TelerikAcademyHomeworks,代码行数:32,代码来源:Startup.cs

示例7: GetChatQueue

 private static Queue GetChatQueue()
 {
     Client client = new Client(
                 "564191224aa03100070000c9",
                 "SI9mlvuSEQqy6o7W5vip4SFNfx0");
     Queue queue = client.Queue("MySimpleChat");
     return queue;
 }
开发者ID:b-slavov,项目名称:Telerik-Software-Academy,代码行数:8,代码来源:Startup.cs

示例8: Post

 // POST api/messages
 public void Post([FromBody]string value)
 {
     Client client = new Client(
     "520fa0723c1e7f000d000002",
     "4hzKpprLTwxNNM01jw0cyNruTvk");
     var queue = client.Queue("JustChat");
     queue.Push(value);
 }
开发者ID:quela,项目名称:myprojects,代码行数:9,代码来源:MessagesController.cs

示例9: SendRealMessageMessage

        public void SendRealMessageMessage(ComplexStiupidShit data)
        {
            string localMachineIpAddress = this.GetIpAddresFromLocalPc();

            var sender = new Client(GlobalConstatns.ProjectID, GlobalConstatns.Token);
            Queue queue = sender.Queue("TelerikDemo");
            queue.Push(string.Format("{{{0}: {1}}}", localMachineIpAddress, data.Text));
        }
开发者ID:M-Yankov,项目名称:AppHarbor,代码行数:8,代码来源:AppHarborService.svc.cs

示例10: Main

        public static void Main()
        {
            Client client = new Client("5649aff573d0cd00060000be", "CxkKy2oQPPvMfD9kQvW9");
            Queue receiveQueue = client.Queue("A");
            Queue sendQueue = client.Queue("B");

            Console.WriteLine("Listening for new messages from IronMQ server:");
            while (true)
            {
                Message msgReceive = receiveQueue.Get();
                if (msgReceive != null)
                {
                    Console.WriteLine(msgReceive.Body);
                    receiveQueue.DeleteMessage(msgReceive);
                }

                SendMsg(sendQueue);
            }
        }
开发者ID:Novkirishki,项目名称:Web-Services-and-Cloud,代码行数:19,代码来源:Startup.cs

示例11: Main

        public static void Main()
        {
            Client client = new Client("564b5ec04aa0310009000103", "fVegtwvQn3N24EGUwHPQ");
            Queue queue = client.Queue("My chat");

            while (true)
            {
                Console.WriteLine("Enter message:");
                string msgSent = Console.ReadLine();
                queue.Push(msgSent);
                Console.WriteLine("Message sent.");
            }
        }
开发者ID:zvet80,项目名称:TelerikAcademyHomework,代码行数:13,代码来源:Sender.cs

示例12: Main

        public static void Main()
        {
            Client client = new Client("56430b319195a8000700000d", "IsjQFsbII7uW3eKBq6zU");
            Queue queue = client.Queue("LiveChat");

            while (true)
            {
                Console.WriteLine("Please enter message to be sent:");
                string msg = Console.ReadLine();
                queue.Push(msg);
                Console.WriteLine("Message sent to IronMQ server.");
            }
        }
开发者ID:dchakov,项目名称:Web-Services-and-Cloud-HW,代码行数:13,代码来源:IronMQSender.cs

示例13: Main

        static void Main()
        {
            Client client = new Client("5648a0c173d0cd0006000090", "IxtQbuTA34qw1nmTDv75");

            Queue queue = client.Queue("Chat app");
            Console.WriteLine("Enter messages to be sent to the IronMQ server:");
            string ipAddress = GetSenderIpAddress();
            while (true)
            {
                string msg = Console.ReadLine();
                queue.Push(string.Format("{0}: {1}", ipAddress, msg));
                Console.WriteLine("Message sent to the IronMQ server.");
            }
        }
开发者ID:Boyan1912,项目名称:Web-Services-and-Cloud,代码行数:14,代码来源:IronMQSender.cs

示例14: Main

 static void Main(string[] args)
 {
     Client client = new Client("564b989373d0cd0006000113", "pvdw0JaLVzKiqEpXHv67");
     Queue queue = client.Queue("Cool-Chat-Room");
     Console.WriteLine("Enter chat message: ");
     var ip = GetIp();
     while (true)
     {
         string msg = Console.ReadLine();
         var result = ip + " : " + msg;
         queue.Push(result);
         Console.WriteLine("Message sent to the server.");
     }
 }
开发者ID:radenkovn,项目名称:Telerik-Homework,代码行数:14,代码来源:MessagePoster.cs

示例15: Main

        public static void Main()
        {
            localMachineIpAddress = GetIpAddresFromLocalPc();

            var sender = new Client(GlobalConstatns.MQProjectID, GlobalConstatns.MQToken);
            Queue queue = sender.Queue("Telerik Demo");

            Console.WriteLine("Send message:");
            while (true)
            {
                string message = Console.ReadLine();
                queue.Push(string.Format(MessageStringFormat, localMachineIpAddress, message));
            }
        }
开发者ID:GAlex7,项目名称:TA,代码行数:14,代码来源:MQSender.cs


注:本文中的Client.Queue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。