Mercurial > silverbladetech
comparison Messaging/Server/UI/MainWindowViewModel.cs @ 27:96fdf58e05b4
Server working with sockets and rabbitmq
author | adminsh@apollo |
---|---|
date | Wed, 21 Mar 2012 19:00:59 +0000 |
parents | 045dac571339 |
children | 4c0dea4760c5 |
comparison
equal
deleted
inserted
replaced
26:045dac571339 | 27:96fdf58e05b4 |
---|---|
1 using System.Windows.Input; | 1 using System; |
2 using System.Windows.Input; | |
2 using Common; | 3 using Common; |
3 using Common.Logger; | 4 using Common.Logger; |
5 using Common.Messages; | |
4 using GalaSoft.MvvmLight; | 6 using GalaSoft.MvvmLight; |
5 using GalaSoft.MvvmLight.Command; | 7 using GalaSoft.MvvmLight.Command; |
6 using System.Windows; | 8 using System.Windows; |
9 using GalaSoft.MvvmLight.Messaging; | |
10 using Server.EndPoints; | |
7 using Server.Interfaces; | 11 using Server.Interfaces; |
8 using Server.Sockets; | 12 using Server.Listeners; |
9 | 13 |
10 namespace Server.UI | 14 namespace Server.UI |
11 { | 15 { |
12 public class MainWindowViewModel : ViewModelBase | 16 public class MainWindowViewModel : ViewModelBase |
13 { | 17 { |
31 | 35 |
32 #endregion | 36 #endregion |
33 | 37 |
34 #endregion | 38 #endregion |
35 | 39 |
36 | |
37 #region DisplayText | |
38 | |
39 public const string DisplayTextPropertyName = "DisplayText"; | |
40 private string _displayText; | |
41 public string DisplayText | |
42 { | |
43 get { return _displayText; } | |
44 set | |
45 { | |
46 if (_displayText == value) return; | |
47 _displayText = value; | |
48 RaisePropertyChanged(() => DisplayText); | |
49 } | |
50 } | |
51 | |
52 #endregion | |
53 | |
54 public ICommand CloseCommand { get; set; } | 40 public ICommand CloseCommand { get; set; } |
55 | 41 |
56 public MessagingEndPoint SocketEndPoint { get; set; } | 42 public BaseEndPoint SocketEndPoint { get; set; } |
57 public MessagingEndPoint RabbitEndPoint { get; set; } | 43 public BaseEndPoint RabbitEndPoint { get; set; } |
58 public MessagingEndPoint RabbitProtoEndPoint { get; set; } | 44 public BaseEndPoint RabbitProtoEndPoint { get; set; } |
59 | 45 |
60 #region Constructor | 46 #region Constructor |
61 | 47 |
62 public MainWindowViewModel() | 48 public MainWindowViewModel() |
63 { | 49 { |
64 IListener listener = new AsyncSocketListener(Settings.SocketsPortNumber); | 50 InitSocketEndPoint(Settings.SocketsPortNumber); |
65 SocketEndPoint = new MessagingEndPoint(listener) | 51 InitRabbitEndPoint(Settings.RabbitPortNumber); |
66 { | 52 InitRabbitProtoEndPoint(Settings.RabbitProtoPortNumber); |
67 DisplayText = "Async Sockets", | |
68 ToolTip = "Listening over TCP/IP on localhost:" + Settings.SocketsPortNumber, | |
69 DisplayCount = 9, | |
70 DisplayLog = "test for display log" | |
71 }; | |
72 | |
73 DisplayText = "Does this work?!"; | |
74 | 53 |
75 CloseCommand = new RelayCommand(CloseCommandExecute); | 54 CloseCommand = new RelayCommand(CloseCommandExecute); |
55 | |
76 } | 56 } |
77 | 57 |
58 private void InitSocketEndPoint(int port) | |
59 { | |
60 IListener listener = new AsyncSocketListener(port); | |
61 SocketEndPoint = new SocketEndPoint(listener) | |
62 { | |
63 DisplayText = "Async Sockets", | |
64 ToolTip = "Listening over TCP/IP on socket localhost:" + port | |
65 }; | |
66 } | |
67 | |
68 private void InitRabbitEndPoint(int port) | |
69 { | |
70 IListener listener = new RabbitQueueListener(port); | |
71 RabbitEndPoint = new RabbitEndPoint(listener) | |
72 { | |
73 DisplayText = "RabbitMQ", | |
74 ToolTip = "Listening..." + port | |
75 }; | |
76 } | |
77 | |
78 private void InitRabbitProtoEndPoint(int port) | |
79 { | |
80 IListener listener = null; | |
81 RabbitProtoEndPoint = new RabbitProtoEndPoint(listener) | |
82 { | |
83 DisplayText = "RabbitMQ with Protobuf-net", | |
84 ToolTip = "Listening...." + port | |
85 }; | |
86 } | |
78 private void CloseCommandExecute() | 87 private void CloseCommandExecute() |
79 { | 88 { |
80 Log.Write("Closing command executed"); | 89 Log.Write("Closing command executed"); |
81 Application.Current.Shutdown(); | 90 Application.Current.Shutdown(); |
82 } | 91 } |