~chipaca/ubuntuone-windows-installer/miscelanea

« back to all changes in this revision

Viewing changes to src/Canonical.UbuntuOne.ProcessDispatcher/JsonMessageProcessor.cs

  • Committer: Manuel de la Pena
  • Date: 2010-11-02 22:01:15 UTC
  • mfrom: (84.4.13 performance_iprove)
  • Revision ID: mandel@themacaque.com-20101102220115-3ys5bku6j6ddwpik
Improve performance by removing the use of WCF since is not required right now.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 * Authors: Manuel de la Peña <manuel.delapena@canonical.com>
19
19
 */
20
20
using System;
 
21
using Canonical.UbuntuOne.Client.Notification;
 
22
using Newtonsoft.Json.Linq;
21
23
 
22
24
namespace Canonical.UbuntuOne.ProcessDispatcher
23
25
{
24
26
    /// <summary>
25
27
    /// Message processor that works with json messages from python.
26
28
    /// </summary>
27
 
    internal class JsonMessageProcessor : IMessageProcessor
 
29
    public class JsonMessageProcessor : IMessageProcessor
28
30
    {
 
31
        #region DI Properties
 
32
 
 
33
        /// <summary>
 
34
        /// Gets and sets the notification view that will be used to send messages to the user.
 
35
        /// </summary>
 
36
        public INotificationIconView NotificationIconView { get; set; } 
 
37
 
 
38
        #endregion
 
39
 
29
40
        /// <summary>
30
41
        /// Will process the message sent by the python code and will perform all the possibly required operations.
31
42
        /// </summary>
32
43
        /// <param name="message"></param>
33
44
        public void ProcessMessage(object message)
34
45
        {
35
 
            throw new NotImplementedException();
 
46
            // a message is a string that will be parsed from json and its value interpretated.
 
47
            var messageObject = (JObject) message;
 
48
            if(string.Compare((string)messageObject["type"], "notify", StringComparison.CurrentCultureIgnoreCase) == 0)
 
49
            {
 
50
                NotificationIconView.ShowNotification(10, (string)messageObject["title"], (string)messageObject["message"]);
 
51
            }
36
52
        }
37
53
    }
38
54
}