Merge pull request #14 from lawrencehj/wvp-28181-2.0
修正上级注册的代码
| | |
| | | }
|
| | |
|
| | |
|
| | | public Request createRegisterRequest(@NotNull ParentPlatform platform, String fromTag, String viaTag) throws ParseException, InvalidArgumentException, PeerUnavailableException {
|
| | | public Request createRegisterRequest(@NotNull ParentPlatform platform, long CSeq, String fromTag, String viaTag) throws ParseException, InvalidArgumentException, PeerUnavailableException {
|
| | | Request request = null;
|
| | | String sipAddress = sipConfig.getSipIp() + ":" + sipConfig.getSipPort();
|
| | | //请求行
|
| | |
| | | MaxForwardsHeader maxForwards = sipFactory.createHeaderFactory().createMaxForwardsHeader(70);
|
| | |
|
| | | //ceq
|
| | | CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(1L, Request.REGISTER);
|
| | | CSeqHeader cSeqHeader = sipFactory.createHeaderFactory().createCSeqHeader(CSeq, Request.REGISTER);
|
| | | request = sipFactory.createMessageFactory().createRequest(requestLine, Request.REGISTER, callIdHeader,
|
| | | cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards);
|
| | |
|
| | |
| | | .createSipURI(platform.getDeviceGBId(), sipAddress));
|
| | | request.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress));
|
| | |
|
| | | ExpiresHeader expires = sipFactory.createHeaderFactory().createExpiresHeader(3600);
|
| | | request.addHeader(expires);
|
| | |
|
| | | return request;
|
| | | }
|
| | |
|
| | | public Request createRegisterRequest(@NotNull ParentPlatform parentPlatform, String fromTag, String viaTag,
|
| | | String callId, String realm, String nonce, String scheme) throws ParseException, PeerUnavailableException, InvalidArgumentException {
|
| | | Request registerRequest = createRegisterRequest(parentPlatform, fromTag, viaTag);
|
| | | Request registerRequest = createRegisterRequest(parentPlatform, 2L, fromTag, viaTag);
|
| | |
|
| | | CallIdHeader callIdHeader = (CallIdHeader)registerRequest.getHeader(CallIdHeader.NAME);
|
| | | callIdHeader.setCallId(callId);
|
| | |
| | | String RESPONSE = DigestUtils.md5DigestAsHex((HA1 + ":" + nonce + ":" + HA2).getBytes());
|
| | |
|
| | | String authorizationHeaderContent = scheme + " username=\"" + parentPlatform.getDeviceGBId() + "\", " + "realm=\""
|
| | | + realm + "\", uri=\"" + uri + "\", response=\"" + RESPONSE + "\", nonce=\""
|
| | | + nonce + "\"";
|
| | | + realm + "\", nonce=\"" + nonce + "\", uri=\"" + uri + "\", response=\"" + RESPONSE + "\"" + ", algorithm=MD5";
|
| | | AuthorizationHeader authorizationHeader = sipFactory.createHeaderFactory().createAuthorizationHeader(authorizationHeaderContent);
|
| | | registerRequest.addHeader(authorizationHeader);
|
| | |
|
| | |
| | | try { |
| | | Request request = null; |
| | | if (realm == null || nonce == null) { |
| | | request = headerProvider.createRegisterRequest(parentPlatform, null, null); |
| | | request = headerProvider.createRegisterRequest(parentPlatform, 1L, null, null); |
| | | }else { |
| | | request = headerProvider.createRegisterRequest(parentPlatform, null, null, callId, realm, nonce, scheme); |
| | | } |
| | |
| | | package com.genersoft.iot.vmp.vmanager.platform; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.genersoft.iot.vmp.common.PageResult; |
| | | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| | | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; |
| | |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import com.genersoft.iot.vmp.conf.SipConfig; |
| | | |
| | | |
| | | @CrossOrigin |
| | | @RestController |
| | |
| | | @Autowired |
| | | private ISIPCommanderForPlatform commanderForPlatform; |
| | | |
| | | @Autowired |
| | | private SipConfig sipConfig; |
| | | |
| | | @GetMapping("/platforms/serverconfig") |
| | | public ResponseEntity<JSONObject> serverConfig() { |
| | | JSONObject result = new JSONObject(); |
| | | result.put("deviceIp", sipConfig.getSipIp()); |
| | | result.put("devicePort", sipConfig.getSipPort()); |
| | | result.put("username", sipConfig.getSipId()); |
| | | result.put("password", sipConfig.getSipPassword()); |
| | | return new ResponseEntity<>(result, HttpStatus.OK); |
| | | } |
| | | |
| | | @GetMapping("/platforms/{count}/{page}") |
| | | public PageResult<ParentPlatform> platforms(@PathVariable int page, @PathVariable int count){ |
| | | |
| | |
| | | <template> |
| | | <div id="addlatform" v-loading="isLoging"> |
| | | <el-dialog title="添加平台" width="70%" top="2rem" :close-on-click-modal="false" :visible.sync="showDialog" :destroy-on-close="true" @close="close()"> |
| | | <div id="shared" style="text-align: right; margin-top: 1rem;"> |
| | | |
| | | <el-dialog |
| | | title="添加平台" |
| | | width="70%" |
| | | top="2rem" |
| | | :close-on-click-modal="false" |
| | | :visible.sync="showDialog" |
| | | :destroy-on-close="true" |
| | | @close="close()" |
| | | > |
| | | <div id="shared" style="text-align: right; margin-top: 1rem"> |
| | | <el-row :gutter="24"> |
| | | <el-col :span="11"> |
| | | <el-form ref="platform1" :rules="rules" :model="platform" label-width="160px" > |
| | |
| | | <el-form-item label="本地端口" prop="devicePort"> |
| | | <el-input v-model="platform.devicePort" :disabled="true"></el-input> |
| | | </el-form-item> |
| | | |
| | | </el-form> |
| | | </el-col> |
| | | <el-col :span="12"> |
| | |
| | | <el-input v-model="platform.keepTimeout"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="信令传输" prop="transport"> |
| | | <el-select v-model="platform.transport" style="width:100%" placeholder="请选择信令传输方式"> |
| | | <el-select |
| | | v-model="platform.transport" |
| | | style="width: 100%" |
| | | placeholder="请选择信令传输方式" |
| | | > |
| | | <el-option label="UDP" value="UDP"></el-option> |
| | | <el-option label="TCP" value="TCP"></el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="字符集" prop="characterSet"> |
| | | <el-select v-model="platform.characterSet" style="width:100%" placeholder="请选择字符集"> |
| | | <el-select |
| | | v-model="platform.characterSet" |
| | | style="width: 100%" |
| | | placeholder="请选择字符集" |
| | | > |
| | | <el-option label="GB2312" value="GB2312"></el-option> |
| | | <el-option label="UTF-8" value="UTF-8"></el-option> |
| | | </el-select> |
| | |
| | | <el-checkbox label="RTCP保活" v-model="platform.rtcp"></el-checkbox> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="primary" @click="onSubmit">{{onSubmit_text}}</el-button> |
| | | <el-button type="primary" @click="onSubmit">{{ |
| | | onSubmit_text |
| | | }}</el-button> |
| | | <el-button @click="close">取消</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | |
| | | |
| | | <script> |
| | | export default { |
| | | name: 'platformEdit', |
| | | name: "platformEdit", |
| | | props: {}, |
| | | computed: { |
| | | |
| | | }, |
| | | computed: {}, |
| | | created() {}, |
| | | data() { |
| | | var deviceGBIdRules = async (rule, value, callback) => { |
| | | console.log(value) |
| | | if (value === '') { |
| | | callback(new Error('请输入设备国标编号')); |
| | | console.log(value); |
| | | if (value === "") { |
| | | callback(new Error("请输入设备国标编号")); |
| | | } else { |
| | | var exit = await this.deviceGBIdExit(value); |
| | | console.log(exit) |
| | | console.log(exit == "true") |
| | | console.log(exit === "true") |
| | | console.log(exit); |
| | | console.log(exit == "true"); |
| | | console.log(exit === "true"); |
| | | if (exit) { |
| | | callback(new Error('设备国标编号已存在')); |
| | | callback(new Error("设备国标编号已存在")); |
| | | }else { |
| | | callback(); |
| | | } |
| | |
| | | characterSet: "GB2312", |
| | | }, |
| | | rules: { |
| | | name: [ |
| | | { required: true, message:"请输入平台名称", trigger: 'blur' } |
| | | ], |
| | | name: [{ required: true, message: "请输入平台名称", trigger: "blur" }], |
| | | serverGBId: [ |
| | | { required: true, message:"请输入SIP服务国标编码", trigger: 'blur' } |
| | | { required: true, message: "请输入SIP服务国标编码", trigger: "blur" }, |
| | | ], |
| | | serverGBDomain: [ |
| | | { required: true, message:"请输入SIP服务国标域", trigger: 'blur' } |
| | | { required: true, message: "请输入SIP服务国标域", trigger: "blur" }, |
| | | ], |
| | | serverIP: [ |
| | | { required: true, message:"请输入SIP服务IP", trigger: 'blur' } |
| | | ], |
| | | serverPort: [ |
| | | { required: true, message:"请输入SIP服务端口", trigger: 'blur' } |
| | | ], |
| | | deviceGBId: [ |
| | | {validator: deviceGBIdRules, trigger: 'blur' } |
| | | ], |
| | | username: [ |
| | | { required: false, message:"请输入SIP认证用户名", trigger: 'blur' } |
| | | ], |
| | | password: [ |
| | | { required: false, message:"请输入SIP认证密码", trigger: 'blur' } |
| | | ], |
| | | expires: [ |
| | | { required: true, message:"请输入注册周期", trigger: 'blur' } |
| | | ], |
| | | keepTimeout: [ |
| | | { required: true, message:"请输入心跳周期", trigger: 'blur' } |
| | | ], |
| | | transport: [ |
| | | { required: true, message:"请选择信令传输", trigger: 'blur' } |
| | | ], |
| | | characterSet: [ |
| | | { required: true, message:"请选择编码字符集", trigger: 'blur' } |
| | | ] |
| | | } |
| | | serverIP: [{ required: true, message: "请输入SIP服务IP", trigger: "blur" }], |
| | | serverPort: [{ required: true, message: "请输入SIP服务端口", trigger: "blur" }], |
| | | deviceGBId: [{ validator: deviceGBIdRules, trigger: "blur" }], |
| | | username: [{ required: false, message: "请输入SIP认证用户名", trigger: "blur" }], |
| | | password: [{ required: false, message: "请输入SIP认证密码", trigger: "blur" }], |
| | | expires: [{ required: true, message: "请输入注册周期", trigger: "blur" }], |
| | | keepTimeout: [{ required: true, message: "请输入心跳周期", trigger: "blur" }], |
| | | transport: [{ required: true, message: "请选择信令传输", trigger: "blur" }], |
| | | characterSet: [{ required: true, message: "请选择编码字符集", trigger: "blur" }], |
| | | }, |
| | | }; |
| | | }, |
| | | methods: { |
| | | openDialog: function (platform, callback) { |
| | | var that = this; |
| | | this.$axios |
| | | .get(`/api/platforms/serverconfig`) |
| | | .then(function (res) { |
| | | console.log(res); |
| | | that.platform.deviceGBId = res.data.username; |
| | | that.platform.deviceIp = res.data.deviceIp; |
| | | that.platform.devicePort = res.data.devicePort; |
| | | that.platform.username = res.data.username; |
| | | that.platform.password = res.data.password; |
| | | }) |
| | | .catch(function (error) { |
| | | console.log(error); |
| | | }); |
| | | this.showDialog = true; |
| | | this.listChangeCallback = callback; |
| | | if (platform != null) { |
| | | this.platform = platform; |
| | | this.onSubmit_text = "保存" |
| | | this.onSubmit_text = "保存"; |
| | | } else { |
| | | } |
| | | |
| | | }, |
| | | onSubmit: function () { |
| | | console.log('onSubmit'); |
| | | console.log("onSubmit"); |
| | | var that = this; |
| | | that.$axios.post(`/api/platforms/save`, that.platform) |
| | | that.$axios |
| | | .post(`/api/platforms/save`, that.platform) |
| | | .then(function (res) { |
| | | console.log(res) |
| | | console.log(res.data == "success") |
| | | console.log(res); |
| | | console.log(res.data == "success"); |
| | | if (res.data == "success") { |
| | | that.$message({ |
| | | showClose: true, |
| | | message: '保存成功', |
| | | type: 'success' |
| | | message: "保存成功", |
| | | type: "success", |
| | | }); |
| | | that.showDialog = false; |
| | | if (that.listChangeCallback != null) { |
| | | that.listChangeCallback() |
| | | that.listChangeCallback(); |
| | | } |
| | | } |
| | | }) |
| | |
| | | }); |
| | | }, |
| | | close: function () { |
| | | console.log('关闭添加视频平台'); |
| | | console.log("关闭添加视频平台"); |
| | | this.showDialog = false; |
| | | this.$refs.platform1.resetFields(); |
| | | this.$refs.platform2.resetFields(); |
| | | }, |
| | | deviceGBIdExit: async function (deviceGbId) { |
| | | var result = false; |
| | | var that = this |
| | | await that.$axios.post(`/api/platforms/exit/${deviceGbId}`) |
| | | var that = this; |
| | | await that.$axios |
| | | .post(`/api/platforms/exit/${deviceGbId}`) |
| | | .then(function (res) { |
| | | result = res.data; |
| | | }) |
| | |
| | | console.log(error); |
| | | }); |
| | | return result; |
| | | |
| | | } |
| | | |
| | | } |
| | | }, |
| | | }, |
| | | }; |
| | | </script> |
| | | |