private void StopServer( object sender, RoutedEventArgs e )
		{
			ServerServiceProxy proxy = new ServerServiceProxy( );
			proxy.StopServer( );
			proxy.Close( );
			proxy.InnerChannel.Dispose( );
		}
		private void ReloadChatPlayerList( object sender, RoutedEventArgs e )
		{
			ServerServiceProxy proxy = new ServerServiceProxy( );
			List<ChatUserItem> players = proxy.GetPlayersOnline( ).ToList( );
			proxy.Close( );
			proxy.InnerChannel.Dispose( );
			if ( PlayerList.Dispatcher.CheckAccess( ) )
			{
				PlayerList.Items.Clear( );
				foreach ( ChatUserItem player in players )
				{
					PlayerList.Items.Add( new ListViewItem { Content = string.Format( "{0} ({1})", player.Username, player.SteamId ), Tag = player } );
				}
			}
			else
			{
				PlayerList.Dispatcher.Invoke( ( ) =>
											  {
												  PlayerList.Items.Clear( );
												  foreach ( ChatUserItem player in players )
												  {
													  PlayerList.Items.Add( new ListViewItem { Content = string.Format( "{0} ({1})", player.Username, player.SteamId ), Tag = player } );
												  }
											  } );
			}
		}
		private void StartServer( object sender, RoutedEventArgs e )
		{
			ServerServiceProxy proxy = new ServerServiceProxy( );
			proxy.StartServer( new StartServerRequest { ConfigurationName = "", ProtocolVersion = new Version( 1, 0, 0 ) } );
			proxy.Close( );
			proxy.InnerChannel.Dispose( );
		}
		public MainWindow( )
		{
			InitializeComponent( );
			ServerServiceProxy proxy = new ServerServiceProxy( );
			chatSessionGuid = proxy.BeginChatSession( );
			proxy.Close( );
			proxy.InnerChannel.Dispose( );
			chatRefreshTimer.Elapsed += chatRefreshTimer_Elapsed;
			chatRefreshTimer.Start(  );
		}
		void chatRefreshTimer_Elapsed( object sender, ElapsedEventArgs e )
		{
			ServerServiceProxy proxy = new ServerServiceProxy( );
			IEnumerable<ChatMessage> chatMessages = proxy.GetChatMessages( chatSessionGuid );
			proxy.Close(  );
			proxy.InnerChannel.Dispose( );
			foreach ( ChatMessage m in chatMessages )
			{
				ChatHistoryTextBox.Dispatcher.Invoke( ( ) => ChatHistoryTextBox.AppendText( string.Format( "\r\n{0} - {1} - {2}", m.Timestamp, m.User, m.Message ) ) );
			}
		}
Esempio n. 6
0
        protected override void OnExit(ExitEventArgs e)
        {
            base.OnExit(e);

            ServerServiceProxy serverServiceProxy = bootstrapper.Container.Resolve <ServerServiceProxy>();

            if (serverServiceProxy != null)
            {
                serverServiceProxy.ServerService.Unsubscribe();
            }
        }
Esempio n. 7
0
        public MessageService(ServerServiceProxy serverServiceProxy, EventAggregator eventAggregator, DataBaseService dataBaseService, FriendsService friendsService)
        {
            this.dataBaseService = dataBaseService;
            this.friendsService  = friendsService;

            this.messages           = new Dictionary <ObjectId, ObservableCollection <Message> >();
            this.serverServiceProxy = serverServiceProxy;

            eventAggregator.GetEvent <MessageEvent>().Subscribe(OnMessageReceived);

            lastMessagesRead = ObjectId.Empty;
        }
Esempio n. 8
0
        public FriendsService(IUnityContainer container, DataBaseService dataBaseService, ServerServiceProxy serverService, EventAggregator eventAggregator)
        {
            this.dataBaseService = dataBaseService;
            this.eventAggregator = eventAggregator;
            Friends = new ObservableCollection <User>();

            this.serverService = serverService;
            this.userId        = serverService.UserInfo.UserID;

            eventAggregator.GetEvent <FriendshipRequestedEvent>().Subscribe(this.OnFriendshipRequested, ThreadOption.BackgroundThread);
            eventAggregator.GetEvent <FriendshipRequestAnswerdEvent>().Subscribe(this.OnFriendshipAnswered);
            eventAggregator.GetEvent <FriendUsernameChanged>().Subscribe(this.OnFriendUsernameChanged);
        }
Esempio n. 9
0
        /// <summary>
        /// registers singleton instances of global services/>
        /// </summary>
        protected override void ConfigureContainer()
        {
            base.ConfigureContainer();

            serverServiceProxy = new ServerServiceProxy(Container.Resolve <EventAggregator>());
            // TODO: change to conainercontrolledlifetimemanager
            // TODO: move audiostreamingservice to chat module as a shared service
            Container.RegisterInstance(audioStreamingService);
            Container.RegisterInstance(dataBaseService);
            Container.RegisterInstance(serverServiceProxy);
            Container.RegisterType <StartService>();
            Container.RegisterType <LoginDialogViewModel>();
        }
Esempio n. 10
0
        public VoiceChatViewModel(AudioStreamingService audioStreamingService, EventAggregator eventAggregator, ServerServiceProxy serverServiceProxy)
        {
            this.audioStreamingService = audioStreamingService;
            this.serverServiceProxy    = serverServiceProxy;
            this.cancelCallCommand     = DelegateCommand <object> .FromAsyncHandler(this.OnCancelCall);

            this.acceptCallCommand = DelegateCommand <object> .FromAsyncHandler(this.OnAcceptCall);

            this.windowLoadedCommand = DelegateCommand <object> .FromAsyncHandler(this.OnWindowLoaded);

            eventAggregator.GetEvent <AcceptedCallEvent>().Subscribe(OnCallAccepted, ThreadOption.UIThread, true);
            eventAggregator.GetEvent <CanceledCallEvent>().Subscribe(OnCallCanceled, ThreadOption.UIThread, true);
        }
		private void ExitServer( object sender, RoutedEventArgs e )
		{
			try
			{
				ServerServiceProxy proxy = new ServerServiceProxy( );
				proxy.Exit( 0 );
				proxy.Close( );
				proxy.InnerChannel.Dispose( );
			}
			catch ( Exception ex )
			{
				MessageBox.Show( ex.Message );
			}
		}
Esempio n. 12
0
        /// <summary>
        /// creates a new instance of the <see cref="OptionsViewModel"/> class
        /// </summary>
        /// <param name="audioStreamingService">will be injected by the <see cref="IUnityContainer"/>, stored in <see cref="audioStreamingService"/></param>
        public OptionsViewModel(AudioStreamingService audioStreamingService, ServerServiceProxy serverService)
        {
            this.audioStreamingService = audioStreamingService;
            this.serverService         = serverService;

            this.inputDeviceSelectionChanged  = new DelegateCommand <object>(this.OnInputDeviceSelectionChanged);
            this.outputDeviceSelectionChanged = new DelegateCommand <object>(this.OnOutputDeviceSelectionChanged);
            this.statusSelectionChanged       = DelegateCommand <object> .FromAsyncHandler(this.OnStatusSelectionChanged);

            this.accountInfoSendCommand = DelegateCommand <object> .FromAsyncHandler(this.OnAccountInfoSendCommand, CanSendAccountInfo);

            InputDevices  = new ObservableCollection <string>(audioStreamingService.GetInputDevice());
            OutputDevices = new ObservableCollection <string>(audioStreamingService.GetOutputDevice());

            List <string> statuses = new List <string>(Enum.GetNames(typeof(Status)));

            statuses.Remove(statuses.Where(status => status.Equals(Status.Web.ToString())).First());
            StatusStrings = statuses;
        }
Esempio n. 13
0
        public ChatViewModel(FriendsService friendsService, MessageService messageService, IUnityContainer container, EventAggregator eventAggregator, IRegionManager regionManager, ServerServiceProxy serverServie)
        {
            if (friendsService == null)
            {
                throw new ArgumentNullException("chatService");
            }

            if (container == null)
            {
                throw new ArgumentNullException("container");
            }

            if (messageService == null)
            {
                throw new ArgumentNullException("messageService");
            }

            username = serverServie.UserInfo.Username;

            this.container      = container;
            this.regionManager  = regionManager;
            this.friendsService = friendsService;
            this.messageService = messageService;

            friends  = new ListCollectionView(friendsService.Friends);
            messages = new ObservableCollection <Message>();

            this.sendCommand = DelegateCommand <object> .FromAsyncHandler(OnSend, CanSend);

            this.callCommand         = new DelegateCommand <object>(this.OnCall, this.CanCall);
            this.windowLoadedCommand = DelegateCommand <object> .FromAsyncHandler(this.OnWindowLoaded);

            this.searchTextBoxChanged  = new DelegateCommand <object>(this.OnSearchTextBoxChanged);
            this.messageTextBoxChanged = new DelegateCommand <object>(this.OnMessageTextBoxChanged);
            this.addFriendCommand      = DelegateCommand <object> .FromAsyncHandler(this.OnAddFriend);

            this.acceptFriendshipCommand = DelegateCommand <object> .FromAsyncHandler(this.OnAcceptFriendship);

            this.declineFriendshipCommand = DelegateCommand <object> .FromAsyncHandler(this.OnDeclineFriendship);

            this.showVoiceChatRequest     = new InteractionRequest <VoiceChatViewModel>();
            this.navigateToProfileCommand = new DelegateCommand <object>(OnNavigateToProfile, CanNavigateToProfile);
            this.deleteFriendCommand      = DelegateCommand <object> .FromAsyncHandler(OnDeleteFriend, CanDeleteFriend);

            FriendsCollectionView.CurrentChanged += SelectedFriendChanged;

            this.userId = container.Resolve <ServerServiceProxy>().UserInfo.UserID;

            eventAggregator.GetEvent <MessageEvent>().Subscribe(OnMessageReceived, ThreadOption.UIThread, true);
            eventAggregator.GetEvent <CallEvent>().Subscribe(OnIncomingCall, ThreadOption.UIThread, true);
            eventAggregator.GetEvent <FriendStatusChangedEvent>().Subscribe(OnFriendStatusChanged, ThreadOption.UIThread, true);
            eventAggregator.GetEvent <FriendshipRequestAnswerdEvent>().Subscribe(OnFriendshipRequestAnswered, ThreadOption.UIThread, true);

            showFriendshipInfo    = false;
            showFriendshipRequest = false;
        }
Esempio n. 14
0
        /// <summary>
        /// creates a new instance of the <see cref="ChatModule"/> class
        /// </summary>
        /// <param name="regionManager">injected by the <see cref="IUnityContainer"/>, stored in <see cref="regionManager"/></param>
        /// <param name="container">injected by the <see cref="IUnityContainer"/>, stored in <see cref="container"/></param>
        /// <param name="audioStreamer">injected by the <see cref="IUnityContainer"/>, stored in <see cref="audioStreamer"/></param>
        public ChatModule(IRegionManager regionManager, IUnityContainer container, ModuleManager moduleManager, AudioStreamingService audioStreamer, ServerServiceProxy serverServiceProxy)
        {
            this.container = container;

            this.audioStreamer = audioStreamer;

            regionManager.RegisterViewWithRegion(RegionNames.MainNavigationRegion, typeof(ChatNavigationItemView));

            this.audioInitWorker    = new BackgroundWorker();
            audioInitWorker.DoWork += audioInitWorker_DoWork;

            moduleManager.LoadModuleCompleted += (s, e) =>
            {
                audioInitWorker.RunWorkerAsync();
            };
        }
Esempio n. 15
0
 public StartService(DataBaseService dataBaseService, ServerServiceProxy serverService)
 {
     this.dataBaseService = dataBaseService;
     this.serverService   = serverService;
 }
 /// <summary>
 /// creates a new instance of the <see cref="HamburgerMenuViewModel"/> class. Initializes the <see cref="profileIcon"/> and <see cref="profileName"/>
 /// </summary>
 public HamburgerMenuViewModel(ServerServiceProxy serverService)
 {
     profileIcon = new BitmapImage(new Uri("pack://application:,,,/Assets/profile_high.jpg"));
     UserInfo    = serverService.UserInfo;
 }
		private void BanPlayer( object sender, RoutedEventArgs e )
		{
			ServerServiceProxy p = new ServerServiceProxy( );
			p.BanPlayer( ( (ChatUserItem)( (ListViewItem)PlayerList.SelectedItem ).Tag ).SteamId );
			p.Close( );
			p.InnerChannel.Dispose( );
		}
		private void RefreshPluginList( object sender, RoutedEventArgs e )
		{
			ServerServiceProxy p = new ServerServiceProxy( );
			IEnumerable<PluginInfo> plugins = p.GetLoadedPluginList( );
			p.Close( );
			p.InnerChannel.Dispose( );

			LoadedPlugins.Items.Clear( );

			foreach ( var plugin in plugins )
			{
				LoadedPlugins.Items.Add( string.Format( "{0} - {1}", plugin.Name, plugin.Version ) );
			}
		}
		private void Window_Closing( object sender, System.ComponentModel.CancelEventArgs e )
		{
			ServerServiceProxy p = new ServerServiceProxy( );
			p.EndChatSession( chatSessionGuid );
			p.Close( );
			p.InnerChannel.Dispose( );
		}