protected void btnSend_Click(object sender, EventArgs e) { //// Create a message entity to contain all necessary data. //NotificationMessage message = new NotificationMessage(); //message.RecipientName = "Admin"; //message.MessageContent = "This is a test notificatiopn" + DateTime.Now.ToLongTimeString(); //if (!string.IsNullOrWhiteSpace(message.RecipientName) && !string.IsNullOrEmpty(message.MessageContent)) //{ // // Call the client adapter to send the message to the particular recipient instantly. // NotificationClientAdapter.Instance.SendMessage(message); //} // Create a message entity to contain all necessary data. NotificationMessageLive message = new NotificationMessageLive(); message.RecipientName = "raju"; message.MessageContent = "This is a test notificatiopn" + DateTime.Now.ToLongTimeString(); if (!string.IsNullOrWhiteSpace(message.RecipientName) && !string.IsNullOrEmpty(message.MessageContent)) { // Call the client adapter to send the message to the particular recipient instantly. NotificationAdapterLive.Instance.SendMessage(message); } }
/// <summary> /// Send a message to a particular recipient. /// </summary> public void SendMessage(NotificationMessageLive message) { if (recipients.ContainsKey(message.RecipientName)) { NotificationRecipientLive client = recipients[message.RecipientName]; client.EnqueueMessage(message); } }
/// <summary> /// This method is called by a sender to send a message to this client. /// </summary> /// <param name="message">the new message</param> public void EnqueueMessage(NotificationMessageLive message) { lock (messageQueue) { messageQueue.Enqueue(message); // Set a new message event. messageEvent.Set(); } }