4.발신전용 API (SBC 연동)발신전용 API (SBC 연동)

Edit

4.1발신전용 API(SBC 연동)

상담앱에서 내선으로 전화를 발신 합니다.

4.1.1API연동 하기

4.1.1.1연동하기

sample Code
<script src="./nxWebApi.js"></script>

4.1.1.2이벤트 (콜백 등록)

sample Code
<script>
    //callback function
    var setChatCallback = function(jsonString) {
           alert('callback' + jsonString);
    };
    // callback 등록
    nxWebApi.SetCallBack(setChatCallback);    
</script>

4.1.1.3전화 발신

[전화 로그인 샘플]

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) 이 발생하지 않을경우는 실제 네트워크로 데이터가 전송이 일어 나지 않았을 경우 입니다.

네트워크가 정상적인지 먼저 체크해 주세요.

4.1.2.4.1SetCallBack

{
  "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
  }
}