Mercurial > silverbladetech
diff 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 |
line wrap: on
line diff
--- a/Messaging/Server/UI/MainWindowViewModel.cs Wed Mar 21 15:39:53 2012 +0000 +++ b/Messaging/Server/UI/MainWindowViewModel.cs Wed Mar 21 19:00:59 2012 +0000 @@ -1,11 +1,15 @@ -using System.Windows.Input; +using System; +using System.Windows.Input; using Common; using Common.Logger; +using Common.Messages; using GalaSoft.MvvmLight; using GalaSoft.MvvmLight.Command; using System.Windows; +using GalaSoft.MvvmLight.Messaging; +using Server.EndPoints; using Server.Interfaces; -using Server.Sockets; +using Server.Listeners; namespace Server.UI { @@ -33,48 +37,53 @@ #endregion - - #region DisplayText - - public const string DisplayTextPropertyName = "DisplayText"; - private string _displayText; - public string DisplayText - { - get { return _displayText; } - set - { - if (_displayText == value) return; - _displayText = value; - RaisePropertyChanged(() => DisplayText); - } - } - - #endregion - public ICommand CloseCommand { get; set; } - public MessagingEndPoint SocketEndPoint { get; set; } - public MessagingEndPoint RabbitEndPoint { get; set; } - public MessagingEndPoint RabbitProtoEndPoint { get; set; } + public BaseEndPoint SocketEndPoint { get; set; } + public BaseEndPoint RabbitEndPoint { get; set; } + public BaseEndPoint RabbitProtoEndPoint { get; set; } #region Constructor public MainWindowViewModel() { - IListener listener = new AsyncSocketListener(Settings.SocketsPortNumber); - SocketEndPoint = new MessagingEndPoint(listener) - { - DisplayText = "Async Sockets", - ToolTip = "Listening over TCP/IP on localhost:" + Settings.SocketsPortNumber, - DisplayCount = 9, - DisplayLog = "test for display log" - }; - - DisplayText = "Does this work?!"; + InitSocketEndPoint(Settings.SocketsPortNumber); + InitRabbitEndPoint(Settings.RabbitPortNumber); + InitRabbitProtoEndPoint(Settings.RabbitProtoPortNumber); CloseCommand = new RelayCommand(CloseCommandExecute); + + } + + private void InitSocketEndPoint(int port) + { + IListener listener = new AsyncSocketListener(port); + SocketEndPoint = new SocketEndPoint(listener) + { + DisplayText = "Async Sockets", + ToolTip = "Listening over TCP/IP on socket localhost:" + port + }; } + private void InitRabbitEndPoint(int port) + { + IListener listener = new RabbitQueueListener(port); + RabbitEndPoint = new RabbitEndPoint(listener) + { + DisplayText = "RabbitMQ", + ToolTip = "Listening..." + port + }; + } + + private void InitRabbitProtoEndPoint(int port) + { + IListener listener = null; + RabbitProtoEndPoint = new RabbitProtoEndPoint(listener) + { + DisplayText = "RabbitMQ with Protobuf-net", + ToolTip = "Listening...." + port + }; + } private void CloseCommandExecute() { Log.Write("Closing command executed");