Mercurial > silverbladetech
comparison Messaging/Server/UI/MainWindowViewModel.cs @ 29:9919ee227c93
msmq added
author | adminsh@apollo |
---|---|
date | Wed, 21 Mar 2012 22:09:18 +0000 |
parents | 4c0dea4760c5 |
children | 7d9de5746f18 |
comparison
equal
deleted
inserted
replaced
28:4c0dea4760c5 | 29:9919ee227c93 |
---|---|
1 using System.Windows.Input; | 1 using System.Windows.Input; |
2 using Common; | 2 using Common; |
3 using Common.Logger; | 3 using Common.Logger; |
4 using Common.Messages; | |
4 using GalaSoft.MvvmLight; | 5 using GalaSoft.MvvmLight; |
5 using GalaSoft.MvvmLight.Command; | 6 using GalaSoft.MvvmLight.Command; |
6 using System.Windows; | 7 using System.Windows; |
7 using Server.EndPoints; | 8 using Server.EndPoints; |
8 using Server.Interfaces; | 9 using Server.Interfaces; |
34 | 35 |
35 #endregion | 36 #endregion |
36 | 37 |
37 public ICommand CloseCommand { get; set; } | 38 public ICommand CloseCommand { get; set; } |
38 | 39 |
39 public BaseEndPoint SocketEndPoint { get; set; } | 40 public MessageEndPoint<MsmqClientMessage, MsmqLogMessage> MsmqEndPoint { get; set; } |
40 public BaseEndPoint RabbitEndPoint { get; set; } | 41 public MessageEndPoint<SocketClientMessage, SocketLogMessage> SocketEndPoint { get; set; } |
41 public BaseEndPoint RabbitProtoEndPoint { get; set; } | 42 public MessageEndPoint<RabbitClientMessage, RabbitLogMessage> RabbitEndPoint { get; set; } |
43 public MessageEndPoint<RabbitProtoClientMessage, RabbitProtoLogMessage> RabbitProtoEndPoint { get; set; } | |
42 | 44 |
43 #region Constructor | 45 #region Constructor |
44 | 46 |
45 public MainWindowViewModel() | 47 public MainWindowViewModel() |
46 { | 48 { |
47 InitSocketEndPoint(Settings.SocketsPortNumber); | 49 InitMsmqEndPoint(Settings.MsmqQueueName); |
48 InitRabbitEndPoint(Settings.RabbitPortNumber, Settings.QueueName); | 50 //InitSocketEndPoint(Settings.SocketsPortNumber); |
51 InitRabbitEndPoint(Settings.RabbitPortNumber, Settings.RabbitQueueName); | |
49 InitRabbitProtoEndPoint(Settings.RabbitProtoPortNumber); | 52 InitRabbitProtoEndPoint(Settings.RabbitProtoPortNumber); |
50 | 53 |
51 CloseCommand = new RelayCommand(CloseCommandExecute); | 54 CloseCommand = new RelayCommand(CloseCommandExecute); |
52 } | 55 } |
53 | 56 |
54 #endregion | 57 #endregion |
55 | 58 |
59 private void InitMsmqEndPoint(string queueName) | |
60 { | |
61 IListener listener = new MsmqListener(queueName); | |
62 MsmqEndPoint = new MessageEndPoint<MsmqClientMessage, MsmqLogMessage>(listener) | |
63 { | |
64 DisplayText = "Microsoft Message Queue", | |
65 ToolTip = string.Format("Listening on msmq queue ({0})", queueName) | |
66 }; | |
67 } | |
68 | |
56 private void InitSocketEndPoint(int port) | 69 private void InitSocketEndPoint(int port) |
57 { | 70 { |
58 IListener listener = new AsyncSocketListener(port); | 71 IListener listener = new AsyncSocketListener(port); |
59 SocketEndPoint = new SocketEndPoint(listener) | 72 SocketEndPoint = new MessageEndPoint<SocketClientMessage, SocketLogMessage>(listener) |
60 { | 73 { |
61 DisplayText = "Async Sockets", | 74 DisplayText = "Async Sockets", |
62 ToolTip = "Listening over TCP/IP on socket localhost:" + port | 75 ToolTip = "Listening over TCP/IP on socket localhost:" + port |
63 }; | 76 }; |
64 } | 77 } |
65 | 78 |
66 private void InitRabbitEndPoint(int port, string queueName) | 79 private void InitRabbitEndPoint(int port, string queueName) |
67 { | 80 { |
68 IListener listener = new RabbitQueueListener(port, queueName); | 81 IListener listener = new RabbitQueueListener(port, queueName); |
69 RabbitEndPoint = new RabbitEndPoint(listener) | 82 RabbitEndPoint = new MessageEndPoint<RabbitClientMessage, RabbitLogMessage>(listener) |
70 { | 83 { |
71 DisplayText = "RabbitMQ", | 84 DisplayText = "RabbitMQ", |
72 ToolTip = "Listening..." + port | 85 ToolTip = "Listening..." + port |
73 }; | 86 }; |
74 } | 87 } |
75 | 88 |
76 private void InitRabbitProtoEndPoint(int port) | 89 private void InitRabbitProtoEndPoint(int port) |
77 { | 90 { |
78 IListener listener = null; | 91 IListener listener = null; |
79 RabbitProtoEndPoint = new RabbitProtoEndPoint(listener) | 92 RabbitProtoEndPoint = new MessageEndPoint<RabbitProtoClientMessage, RabbitProtoLogMessage>(listener) |
80 { | 93 { |
81 DisplayText = "RabbitMQ with Protobuf-net", | 94 DisplayText = "RabbitMQ with Protobuf-net", |
82 ToolTip = "Listening...." + port | 95 ToolTip = "Listening...." + port |
83 }; | 96 }; |
84 } | 97 } |
98 | |
85 private void CloseCommandExecute() | 99 private void CloseCommandExecute() |
86 { | 100 { |
87 Log.Write("Closing command executed"); | 101 Log.Write("Closing command executed"); |
88 Application.Current.Shutdown(); | 102 Application.Current.Shutdown(); |
89 } | 103 } |