public void should_reload_list_from_internal_repository_when_codec_added() { var newRegisteredSip = new RegisteredSip() { SIP = "c" }; A.CallTo(() => _internalRegisteredSipRepository.UpdateRegisteredSip(newRegisteredSip)).Returns( new KamailioMessageHandlerResult() { ChangedObjectId = Guid.NewGuid(), ChangeStatus = KamailioMessageChangeStatus.CodecAdded }); _sut.GetCachedRegisteredSips(); A.CallTo(() => _internalRegisteredSipRepository.GetCachedRegisteredSips()).MustHaveHappened(Repeated.Exactly.Once); _sut.UpdateRegisteredSip(newRegisteredSip); A.CallTo(() => _internalRegisteredSipRepository.GetCachedRegisteredSips()).MustHaveHappened(Repeated.Exactly.Once); _sut.GetCachedRegisteredSips(); A.CallTo(() => _internalRegisteredSipRepository.GetCachedRegisteredSips()).MustHaveHappened(Repeated.Exactly.Twice); }
public KamailioMessageHandlerResult RegisterSip(KamailioRegistrationMessage sipMessage) { var sip = new RegisteredSip { IP = sipMessage.Ip, Port = sipMessage.Port, ServerTimeStamp = sipMessage.UnixTimeStamp, SIP = sipMessage.Sip.UserAtHost, UserAgentHead = sipMessage.UserAgent, Username = sipMessage.Username, DisplayName = sipMessage.ToDisplayName, Expires = sipMessage.Expires }; return(_sipRepository.UpdateRegisteredSip(sip)); }
public SipEventHandlerResult RegisterCodec(SipRegistrationMessage sipMessage) { var userAgentRegistration = new UserAgentRegistration( sipUri: sipMessage.Sip.UserAtHost, userAgentHeader: sipMessage.UserAgent, username: sipMessage.Sip.UserAtHost, displayName: string.IsNullOrEmpty(sipMessage.ToDisplayName) ? sipMessage.FromDisplayName : sipMessage.ToDisplayName, registrar: sipMessage.Registrar, ipAddress: sipMessage.Ip, port: sipMessage.Port, expirationTimeSeconds: sipMessage.Expires, serverTimeStamp: sipMessage.UnixTimeStamp ); return(_sipRepository.UpdateRegisteredSip(userAgentRegistration)); }
public void RegisterSip(string sipAddress, string ip, string displayName, string userAgent) { var userAgentRegistration = new UserAgentRegistration( sipUri: sipAddress, userAgentHeader: userAgent, username: sipAddress, displayName: displayName, registrar: string.Empty, ipAddress: ip, port: 5060, expirationTimeSeconds: 60, serverTimeStamp: 0 ); var changeStatus = _registeredSipRepository.UpdateRegisteredSip(userAgentRegistration); Console.WriteLine("Registered {0} with result: {1}", sipAddress, changeStatus); }
public void RegisterSip(string sipAddress, string ip, string displayName, string userAgent) { var sip = new RegisteredSip { IP = ip, Port = 5060, ServerTimeStamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds(), SIP = sipAddress, UserAgentHead = userAgent, Username = sipAddress, DisplayName = displayName, Expires = 60 }; var changeStatus = _registeredSipRepository.UpdateRegisteredSip(sip); Console.WriteLine("Registered {0} with result: {1}", sip.SIP, changeStatus); }
public KamailioMessageHandlerResult UpdateRegisteredSip(RegisteredSip registeredSip) { var result = _internalRepository.UpdateRegisteredSip(registeredSip); // When reregistration of codec already in cache, just update timestamp if (result.ChangeStatus == KamailioMessageChangeStatus.NothingChanged && result.ChangedObjectId != Guid.Empty) { var regSip = GetCachedRegisteredSips().FirstOrDefault(rs => rs.Id == result.ChangedObjectId); if (regSip != null) { regSip.Updated = DateTime.UtcNow; return(result); } } // Otherwise reload cache. _lazyCache.ClearRegisteredSips(); return(result); }
public SipEventHandlerResult UpdateRegisteredSip(UserAgentRegistration userAgentRegistration) { var result = _internalRepository.UpdateRegisteredSip(userAgentRegistration); // When reregistration of codec already in cache, just update timestamp if (result.ChangeStatus == SipEventChangeStatus.NothingChanged && result.ChangedObjectId != Guid.Empty) { // TODO: When GetRegisteredSips is gone, decide over this //var regSip = GetRegisteredSips().FirstOrDefault(rs => rs.Id == result.ChangedObjectId); //if (regSip != null) //{ // regSip.Updated = DateTime.UtcNow; // return result; //} return(result); } // Otherwise reload cache. _lazyCache.ClearRegisteredUserAgents(); return(result); }