模拟设备注册

This commit is contained in:
shikong 2023-09-13 02:47:59 +08:00
parent 804032b841
commit 96021addb4
2 changed files with 4 additions and 3 deletions

View File

@ -55,7 +55,7 @@ public class SipListenerImpl implements SipListener {
log.debug("{} {}", method, response);
// Success
if (((status >= Response.OK) && (status < Response.MULTIPLE_CHOICES)) || status == Response.UNAUTHORIZED) {
if (((status >= Response.OK) && (status < Response.MULTIPLE_CHOICES)) || status == Response.UNAUTHORIZED || status == Response.FORBIDDEN) {
log.debug("传入响应 method => {}", method);
Optional.ofNullable(responseProcessor.get(method)).ifPresent(processor -> {
processor.process(responseEvent);

View File

@ -97,6 +97,7 @@ public class RegisterService {
@Override
public void onNext(SIPResponse response) {
int statusCode = response.getStatusCode();
if (statusCode == Response.UNAUTHORIZED && !usedAuthorization) {
usedAuthorization = true;
WWWAuthenticateHeader authorizationHeader = (WWWAuthenticateHeader) response.getHeader(WWWAuthenticateHeader.NAME);
@ -114,9 +115,9 @@ public class RegisterService {
return;
}
if (statusCode == Response.UNAUTHORIZED) {
if (statusCode == Response.UNAUTHORIZED || statusCode == Response.FORBIDDEN) {
this.onComplete();
String reason = MessageFormat.format("设备: {0}({1}), 注册失败, 认证失败", device.getDeviceCode(), device.getGbDeviceId());
String reason = MessageFormat.format("设备: {0}({1}), 注册失败: 认证失败", device.getDeviceCode(), device.getGbDeviceId());
log.error(reason);
result.complete(JsonResponse.error(reason));
return;