本文整理汇总了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();
}
示例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.");
}
}
}
示例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();
}
示例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);
}
示例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");
}
示例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.");
}
}
}
示例7: GetChatQueue
private static Queue GetChatQueue()
{
Client client = new Client(
"564191224aa03100070000c9",
"SI9mlvuSEQqy6o7W5vip4SFNfx0");
Queue queue = client.Queue("MySimpleChat");
return queue;
}
示例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);
}
示例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));
}
示例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);
}
}
示例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.");
}
}
示例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.");
}
}
示例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.");
}
}
示例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.");
}
}
示例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));
}
}