Search in sources :

Example 1 with InitiatePrivateChatEvent

use of com.faforever.client.chat.InitiatePrivateChatEvent in project downlords-faf-client by FAForever.

the class FriendOnlineNotifier method onUserOnline.

@Subscribe
public void onUserOnline(UserOnlineEvent event) {
    String username = event.getUsername();
    Player player = playerService.getPlayerForUsername(username);
    if (player != null && player.getSocialStatus() == SocialStatus.FRIEND) {
        audioService.playFriendOnlineSound();
        notificationService.addNotification(new TransientNotification(i18n.get("friend.nowOnlineNotification.title", username), i18n.get("friend.nowOnlineNotification.action"), IdenticonUtil.createIdenticon(player.getId()), actionEvent -> {
            eventBus.post(new NavigateEvent(NavigationItem.CHAT));
            eventBus.post(new InitiatePrivateChatEvent(username));
        }));
    }
}
Also used : TransientNotification(com.faforever.client.notification.TransientNotification) IdenticonUtil(com.faforever.client.util.IdenticonUtil) SocialStatus(com.faforever.client.chat.SocialStatus) InitiatePrivateChatEvent(com.faforever.client.chat.InitiatePrivateChatEvent) NavigationItem(com.faforever.client.main.event.NavigationItem) NavigateEvent(com.faforever.client.main.event.NavigateEvent) TransientNotification(com.faforever.client.notification.TransientNotification) EventBus(com.google.common.eventbus.EventBus) Inject(javax.inject.Inject) NotificationService(com.faforever.client.notification.NotificationService) AudioService(com.faforever.client.audio.AudioService) Component(org.springframework.stereotype.Component) PostConstruct(javax.annotation.PostConstruct) Subscribe(com.google.common.eventbus.Subscribe) I18n(com.faforever.client.i18n.I18n) NavigateEvent(com.faforever.client.main.event.NavigateEvent) InitiatePrivateChatEvent(com.faforever.client.chat.InitiatePrivateChatEvent) Subscribe(com.google.common.eventbus.Subscribe)

Aggregations

AudioService (com.faforever.client.audio.AudioService)1 InitiatePrivateChatEvent (com.faforever.client.chat.InitiatePrivateChatEvent)1 SocialStatus (com.faforever.client.chat.SocialStatus)1 I18n (com.faforever.client.i18n.I18n)1 NavigateEvent (com.faforever.client.main.event.NavigateEvent)1 NavigationItem (com.faforever.client.main.event.NavigationItem)1 NotificationService (com.faforever.client.notification.NotificationService)1 TransientNotification (com.faforever.client.notification.TransientNotification)1 IdenticonUtil (com.faforever.client.util.IdenticonUtil)1 EventBus (com.google.common.eventbus.EventBus)1 Subscribe (com.google.common.eventbus.Subscribe)1 PostConstruct (javax.annotation.PostConstruct)1 Inject (javax.inject.Inject)1 Component (org.springframework.stereotype.Component)1