コード例 #1
0
        public async Task SendMessage(string recipientLogin, string textMessage)
        {
            var senderLogin = Context.User.Identity.Name;
            await Clients.Caller.SendAsync("ReceiveMessage", senderLogin, textMessage, DateTime.Now.ToString("HH:mm, dd MMM"));

            var recipientConnected = ConnectedUsers.TryGetValue(recipientLogin, out var recipientProxy);

            if (recipientConnected)
            {
                await recipientProxy.SendAsync("ReceiveMessage", senderLogin, textMessage, DateTime.Now.ToString());
            }

            messengerService.SendMessage(senderLogin, recipientLogin, textMessage);
        }
コード例 #2
0
        // DELETE api/<controller>/5
        public IHttpActionResult Delete(int id)
        {
            var existingStudent = Datos.possibleDestinations.Where(s => s.IdInventario == id).FirstOrDefault();

            if (existingStudent != null)
            {
                Datos.possibleDestinations.Remove(existingStudent);

                messengerService.SendMessage(id);
            }
            else
            {
                return(NotFound());
            }

            return(Ok(HttpStatusCode.OK));
        }