4.1발신전용 API(SBC 연동)
상담앱에서 내선으로 전화를 발신 합니다.
4.1.1API연동 하기
4.1.1.1연동하기
nxWebApi.js를 html에 소스 추가합니다.
- sample Code
<script src="./nxWebApi.js"></script>
4.1.1.2이벤트 (콜백 등록)
통화 상태 등 Method 를 실행후 이벤트를 받기 위해서는 반드시 이벤트(콜백 함수)를 등록해야 합니다.
이벤트로 전달되는 값은 json 형식의 string 값입니다.
- sample Code
<script> //callback function var setChatCallback = function(jsonString) { alert('callback' + jsonString); }; // callback 등록 nxWebApi.SetCallBack(setChatCallback); </script>
4.1.1.3전화 발신
전화 발신을 위해서는 Realm 정보, 웹 접속 URL, DN 정보 가 필요합니다.
모바일의 경우는 pushKey 가 추가로 필요합니다.
[전화 로그인 샘플]
nxWebApi. directCall('nexuscommunity.net', '1000', '01012345678', 'wss://sbc.nexuscommunity.net:6081', '');
- sample Code
//callback function var setChatCallback = function(jsonString) { var event = JSON.parse(jsonString); if (event) { switch(event.Type){ case 'Connecting': console.log("서버 접속 시도..."); break; case 'Ringing': console.log("발신중"); break; case 'InCall': console.log("통화연결"); break; case 'Clear': console.log("통화종료 또는 서버 접속 실패"); break; } } }; nxWebApi.SetCallBack(setChatCallback); var result = nxWebApi. directCall('nexuscommunity.net', '1000', '01012345678', 'wss://sbc.nexuscommunity.net:6081', ''); if(result != 0){ alert('발신 실패 '); }
4.1.1.4음소거(Mute)
통화중 자신의 음성을 상대방에서 전달 하지 않습니다.
- sample Code
// on nxWebApi.Mute('Audio', true); //off nxWebApi.Mute('Audio', false);
4.1.1.5통화 종료
통화 종료 합니다.
- sample Code
// 접속 종료 callback var setChatCallback = function(jsonString) { var event = JSON.parse(jsonString); if (event) { switch(event.Type){ case 'Clear': console.log("통화 종료"); break; } } ... }; // 통화 종료 nxWebApi.Clear();
4.1.2기능리스트
4.1.2.1발신
nxWebApi.directCall(realm, dn_number, tel_number, websocket_url, push_token);
- Parameters
Name | Type | Descrption |
---|---|---|
realm | string | 서버명(realm) ex) "nexuscommunity.net" |
dn_number | string | 내선번호 |
tel_name | string | 발신자 전화번호 정보 고객 임으로 값(고객전화번호, 사용자 id) - 한글사용불가 ex) "01012345678 |
websocket_url | string | 웹소켓 주소 -U PBX 주소(ws는 6080 , wss 는 6081) 고객 임으로 값(고객전화번호, 사용자 id) - 한글사용불가 ex) "01012345678 |
push_token | string | 모바일 푸쉬 토큰(미사용시 : "default") - 모바일에서만 사용 |
- Return value
구분 | Type | Descrption |
---|---|---|
반환값 | Int | 성공 : 0 실패 : -1 |
- Example code
var result = nxWebApi.directCall('nexuscommunity.net', '3001', '01012345678', 'ws://10.10.30.71:6080', ''); if(result != 0){ alert('발신 failed.'); }
4.1.2.2통화 종료
- Function
nxWebApi.Clear();
- Parameters
None.
- Return value
구분 | Type | Descrption |
---|---|---|
반환값 | Int | 성공 : 0 실패 : -1 |
4.1.2.3음소거(Mute)
- Function
nxWebApi.Mute(type,enable);
- Parameters
Name | Type | Descrption |
---|---|---|
type | string | 'Audio': 음성 , 'Video' : 영상 |
enable | bool | true: 음소거(Video 일 경우 미송출) , false: 미적용 |
- Return value
구분 | Type | Descrption |
---|---|---|
반환값 | Int | 성공 : 0 실패 : -1 |
4.1.2.4이벤트(콜백) Type별 정의
호출시 이벤트(Callback) 데이터에 대한 설명 입니다.
이벤트(Callback) 이 발생하지 않을경우는 실제 네트워크로 데이터가 전송이 일어 나지 않았을 경우 입니다.
네트워크가 정상적인지 먼저 체크해 주세요.
4.1.2.4.1SetCallBack
이벤트(Callback)설정 시 발생합니다.
{ "Type": "SetCallBack", "Data": { "result": "Success" } }
4.1.2.5Connecting
서버 연결 시도 시 발생합니다.
{ "Kind": "SIP", "Type": "Connecting", "Data": { "status": "connecting", "desc": "Call in progress...", "dn": "2590", "id": 2 } }
4.1.2.6Trying
통화 연결 시도 시 발생합니다.
{ "Kind": "SIP", "Type": "Trying", "Data": { "status": " i_ao_request", "desc": "Trying", "dn": "3008", "id": 7 } }
4.1.2.7Ringing
통화 연결 중일 시 발생합니다.
{ "Kind": "SIP", "Type": "Ringing", "Data": { "status": " i_ao_request", "desc": "Ringing", "dn": "3008", "id": 7 } }
4.1.2.8InCall
통화 연결 성공 시 발생합니다.
{ "Kind": "SIP", "Type": "InCall", "Data": { "status": "connected", "desc": "In call", "dn": "3008", "id": 7 } }
4.1.2.9Clear
통화 종료 시 발생합니다.
{ "Kind": "SIP", "Type": "Clear", "Data": { "status": "terminated", "desc": "Call terminated", "dn": "2590", "id": 5 } }