我想创建一个与X-lite SIP电话通信的Web应用程序。我找到了API文档点击here但我不明白我应该如何解析数据以获取请求。例如GET / status" phone"。我知道只使用简单的请求作为GET / showHistory。谢谢你的建议。
function WebSocketTest(){
var ws = new WebSocket("wss://cpclientapi.softphone.com:9002/counterpath/socketapi/v1");
ws.onopen = function (event) {
//here I dont know how to write xml request from documentation
//for example GET /status "phone"
ws.send('GET /showHistory');
};
ws.onerror = function(error){
console.log('Error detected: ' + error);
}
ws.onmessage = function(messageEvent) {
if (typeof messageEvent.data === "string"){
console.log("received text data from the server: " + messageEvent.data);
} else if (messageEvent.data instanceof Blob){
console.log("Blob data received")
}
};
}
答案 0 :(得分:0)
尝试使用localhost:9002
function WebSocketTest(){
var ws = new WebSocket("wss://localhost:9002/counterpath/socketapi/v1");
ws.onopen = function (event) {
//here I dont know how to write xml request from documentation
//for example GET /status "phone"
ws.send('GET /showHistory');
};
ws.onerror = function(error){
console.log('Error detected: ' + error);
}
ws.onmessage = function(messageEvent) {
if (typeof messageEvent.data === "string"){
console.log("received text data from the server: " + messageEvent.data);
} else if (messageEvent.data instanceof Blob){
console.log("Blob data received")
}
};
}