Example #1
0
        public async Task <IActionResult> PutSIPDomain(Guid id, SIPDomain SIPDomain)
        {
            if (id != SIPDomain.ID)
            {
                return(BadRequest());
            }

            _context.Entry(SIPDomain).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SIPDomainExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <ActionResult <string> > GetSignalsForCaller(string to, string from, WebRTCSignalTypesEnum type = WebRTCSignalTypesEnum.any)
        {
            if (string.IsNullOrEmpty(to) || string.IsNullOrEmpty(from))
            {
                return(BadRequest());
            }

            var query = _context.WebRTCSignals.Where(x =>
                                                     x.To.ToLower() == to.ToLower() &&
                                                     x.From.ToLower() == from.ToLower() &&
                                                     x.DeliveredAt == null);

            if (type != WebRTCSignalTypesEnum.any)
            {
                query = query.Where(x => x.SignalType == type.ToString());
            }

            var nextSignal = await query
                             .OrderBy(x => x.Inserted)
                             .FirstOrDefaultAsync();

            if (nextSignal != null)
            {
                nextSignal.DeliveredAt = DateTime.UtcNow.ToString("o");
                await _context.SaveChangesAsync();

                return(nextSignal.Signal);
            }
            else
            {
                return(NoContent());
            }
        }