模拟设备注册
This commit is contained in:
parent
804032b841
commit
96021addb4
@ -55,7 +55,7 @@ public class SipListenerImpl implements SipListener {
|
|||||||
log.debug("{} {}", method, response);
|
log.debug("{} {}", method, response);
|
||||||
|
|
||||||
// Success
|
// 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);
|
log.debug("传入响应 method => {}", method);
|
||||||
Optional.ofNullable(responseProcessor.get(method)).ifPresent(processor -> {
|
Optional.ofNullable(responseProcessor.get(method)).ifPresent(processor -> {
|
||||||
processor.process(responseEvent);
|
processor.process(responseEvent);
|
||||||
|
@ -97,6 +97,7 @@ public class RegisterService {
|
|||||||
@Override
|
@Override
|
||||||
public void onNext(SIPResponse response) {
|
public void onNext(SIPResponse response) {
|
||||||
int statusCode = response.getStatusCode();
|
int statusCode = response.getStatusCode();
|
||||||
|
|
||||||
if (statusCode == Response.UNAUTHORIZED && !usedAuthorization) {
|
if (statusCode == Response.UNAUTHORIZED && !usedAuthorization) {
|
||||||
usedAuthorization = true;
|
usedAuthorization = true;
|
||||||
WWWAuthenticateHeader authorizationHeader = (WWWAuthenticateHeader) response.getHeader(WWWAuthenticateHeader.NAME);
|
WWWAuthenticateHeader authorizationHeader = (WWWAuthenticateHeader) response.getHeader(WWWAuthenticateHeader.NAME);
|
||||||
@ -114,9 +115,9 @@ public class RegisterService {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (statusCode == Response.UNAUTHORIZED) {
|
if (statusCode == Response.UNAUTHORIZED || statusCode == Response.FORBIDDEN) {
|
||||||
this.onComplete();
|
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);
|
log.error(reason);
|
||||||
result.complete(JsonResponse.error(reason));
|
result.complete(JsonResponse.error(reason));
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user