public void with_async_and_a_single_channel_the_request_is_made() { _pusher.TriggerAsync(channelName, eventName, eventData, callback); _subClient.Received().ExecuteAsync( Arg.Any <IRestRequest>(), Arg.Any <Action <IRestResponse, RestRequestAsyncHandle> >()); }
public JsonResult SendMessage() { if (_session.CurrentUser == null) { return(Json(new ErrorMessage { Status = HttpStatusCode.BadRequest, Message = ErrorMessages.UserNotLogged })); } Message message; if (Request.Form["message"].Equals(AppSettings.CommandChat)) { message = new Message() { AddedBy = null, AddedBy_ID = _session.BotUser.ID, Group = null, Group_ID = _session.CurrentGroup.ID, CreatedDate = DateTime.Now, IsBoot = true }; var json = JsonConvert.SerializeObject(message); SendCommandMessageMq(json, _session.CurrentUser.ID.ToString()); } else { message = new Message() { AddedBy = null, AddedBy_ID = _session.CurrentUser.ID, Text = Request.Form["message"], Group = null, Group_ID = _session.CurrentGroup.ID, CreatedDate = DateTime.Now, IsBoot = false }; _db.Messages.Add(message); _db.SaveChanges(); } message.AddedBy = _session.CurrentUser; message.Group = _session.CurrentGroup; _pusher.TriggerAsync( AppSettings.PartialGroupName + message.Group.ID, AppSettings.NewMessageEvent, message, new TriggerOptions() { SocketId = Request.Form["socket_id"] } ); return(Json(message)); }
public void It_should_return_a_200_response_async() { var waiting = new AutoResetEvent(false); ITriggerResult asyncResult = null; _pusher.TriggerAsync("my-channel", "my_event", new { hello = "world" }, (ITriggerResult result) => { asyncResult = result; waiting.Set(); }); waiting.WaitOne(5000); Assert.AreEqual(HttpStatusCode.OK, asyncResult.StatusCode); }
public async Task InvokeAsync(GiveSyncInput input, TraceWriter log) { var board = await _boardManager.GetAsync(input.BoardId, input.Password) ?? throw new UserFriendlyException("The board does not exist."); var triggerResult = await _pusher.TriggerAsync(board.ToString(), Sync_GiveSync.EventName, new Sync_GiveSync { AskForSyncClientId = input.AskForSyncClientId, BoardItems = input.BoardItems }); if (triggerResult.StatusCode != HttpStatusCode.OK) { throw new ApplicationException($"Cannot publish {Sync_GiveSync.EventName}. {JsonConvert.SerializeObject(triggerResult)}"); } }
public async Task InvokeAsync(CreateBoardItemInput input, TraceWriter log) { var board = await _boardManager.GetAsync(input.BoardId, input.Password) ?? throw new UserFriendlyException("The board does not exist."); var triggerResult = await _pusher.TriggerAsync(board.ToString(), BoardItem_Create.EventName, new BoardItem_Create { Type = input.Type }); if (triggerResult.StatusCode != HttpStatusCode.OK) { throw new ApplicationException($"Cannot publish {BoardItem_Create.EventName}. {JsonConvert.SerializeObject(triggerResult)}"); } }
public async Task <JoinBoardOutput> InvokeAsync(JoinBoardInput input, TraceWriter log) { var board = await _boardManager.GetAsync(input.BoardId, input.Password) ?? throw new Exception("The board does not exist."); var clientId = Guid.NewGuid().ToString(); var triggerResult = await _pusher.TriggerAsync(board.ToString(), Board_Join.EventName, new Board_Join { ClientId = clientId }); if (triggerResult.StatusCode != HttpStatusCode.OK) { log.Error($"Cannot publish {Board_Join.EventName}. {JsonConvert.SerializeObject(triggerResult)}"); } return(new JoinBoardOutput { Channel = board.ToString(), ClientId = clientId }); }
public void Trigger(string[] channels, string eventName, object paramData) { _pusher.TriggerAsync(channels, eventName, paramData); }
public async void url_resource_is_in_expected_format() { await _pusher.TriggerAsync(_channelName, _eventName, _eventData); #pragma warning disable 4014 _subPusherClient.Received().ExecutePostAsync( #pragma warning restore 4014 Arg.Is <IPusherRestRequest>( x => x.ResourceUri.StartsWith("/apps/" + Config.AppId + "/events?") ) ); }
public async Task It_should_return_a_200_response_async() { ITriggerResult asyncResult = await _pusher.TriggerAsync("my-channel", "my_event", new { hello = "world" }); Assert.AreEqual(HttpStatusCode.OK, asyncResult.StatusCode); }