private void ReceiveMessage(ExternalMessage m) { Task.Run(() => { _helper.UnPackSendReceivedMessage(m); }); }
public Task PushEndOfMeetingAsync(string botName, string userId) { var message = ConfigService.Get(Constants.TemplateMessage3); var pushData = new ExternalMessage { Count = 1, ForcedState = string.Empty, Messages = new List <string> { message } }; return(PerformPushRequest(botName, userId, pushData)); }
private async Task PerformPushRequest(string botName, string userId, ExternalMessage pushData) { var req = new RestRequest("push/{botName}", Method.POST); req.AddUrlSegment("botName", botName); req.AddQueryParameter("id", userId); req.AddQueryParameter("channel", "spark"); req.AddJsonBody(pushData); var response = await _restClient.ExecuteTaskAsync(req); Trace.TraceInformation("[MeetingService.PushRemoteChatService] response: " + response.Content); if (response.StatusCode != HttpStatusCode.OK) { throw new HttpException((int)HttpStatusCode.OK, "Failed to push answer", response.ErrorException); } }
public Task PushRemoteChatService(string botName, string userId, string userName) { //0 - userId, 1 - userName const string templatePerson = "<@personId:{0}|{1}>"; var templateMsg1 = string.Format(ConfigService.Get(Constants.TemplateMessage1), templatePerson); var templateMsg2 = ConfigService.Get(Constants.TemplateMessage2); var pushData = new ExternalMessage { Count = 1, ForcedState = ConfigService.Get(Constants.ForcedState), Messages = new List <string> { string.Format(templateMsg1, userId, userName), templateMsg2 } }; return(PerformPushRequest(botName, userId, pushData)); }
private void Send <T>(ExternalMessage externalMessage) where T : BaseTransportMessage { _m.SendAsync <T>(externalMessage.Message as T); }
public void UnPackSendReceivedMessage(ExternalMessage m) { var generic = _generics.GetOrAdd(m.Type, t => _sendMethod.MakeGenericMethod(m.Type)); generic.Invoke(this, new object[] { m }); }