public async Task Should_send_request() { var context = await this.SetupContext(); var subject = new RoomNotificationHandler( context, this.mediator.Object, this.messageFactory.Object, this.connectionIdStore.Object); var notification = new RoomNotification(GameId); await subject.Handle(notification, default); var playerIds = new[] { HostConnectionId, ChallengerConnectionId }; this.mediator.Verify(x => x.Send( It.Is <HubGroupNotify.Request>( y => y.Group == GameId.ToString() && y.Message == Message && new HashSet <string>(y.Excluded).SetEquals(playerIds)), It.IsAny <CancellationToken>())); }
void HandlePlayerOnline(RoomNotification roomNotification) { var playerId = roomNotification.JoinRoom.Member.ActorId; var player = GetPlayer(playerId); if (player == null) { Logger.Error("No player id: {0} when player is offline"); return; } player.IsActive = true; Client.OnPlayerActivityChanged?.Invoke(player); }
void HandlePlayerOffline(RoomNotification roomNotification) { var playerId = roomNotification.InitByActor; var player = GetPlayer(playerId); if (player == null) { Logger.Error("No player id: {0} when player is offline"); return; } player.IsActive = false; Client.OnPlayerActivityChanged?.Invoke(player); }
void HandleRoomKicked(RoomNotification roomNotification) { var appInfo = roomNotification.AppInfo; if (appInfo != null) { var code = appInfo.AppCode; var reason = appInfo.AppMsg; Client.OnRoomKicked?.Invoke(code, reason); } else { Client.OnRoomKicked?.Invoke(null, null); } }
protected override IEnumerable <Paragraph> GetParagraphsFromNotification(RoomNotification roomNotification) { var paragraphs = new List <Paragraph>(); var p = new Paragraph(); p.Inlines.Add(new Run { Text = roomNotification.Text }); paragraphs.Add(p); if (GetParagraphsFromNotificationCalled != null) { GetParagraphsFromNotificationCalled(this, new EventArgs()); } return(paragraphs); }
public HttpResponseMessage Notification(RoomNotification message) { try { var hub = GlobalHost.ConnectionManager.GetHubContext <ChatHub>(); hub.Clients.Group(message.Item.Room.Id).roomMessage(message.Item.Room.Id, message.Item.Message.From ?? "Self", message.Item.Message.MessageText, null); return(Request.CreateResponse(HttpStatusCode.Accepted, true)); } catch (Exception e) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e.Message)); } }
public async Task Should_get_message_with_correct_parameters() { var context = await this.SetupContext(); var subject = new RoomNotificationHandler( context, this.mediator.Object, this.messageFactory.Object, this.connectionIdStore.Object); var notification = new RoomNotification(GameId); await subject.Handle(notification, default); this.messageFactory.Verify(x => x.Create( It.Is <Messages.GameState.MessageData>( y => y.GameId == GameId && !y.PlayerId.HasValue))); }