MESIBO Web(javascript), 对方收不到消息

MESIBO Web(javascript), not receiving message in other end

我从 MESIBO API 创建了两个测试用户,以测试他们之间的消息传递。 在两个文件中创建完全相同的脚本,并在一个文件中添加发送功能,以向第二个用户发送消息。 我尝试了第二个用户的 令牌、UID 和地址 但消息是从第一个用户发送的,但第二个用户的脚本侦听器没有捕捉到它。两个用户令牌,appid(应用程序名称)都是有效的,我什至在 HTTPS 连接 中也尝试过,但仍然无法在另一端收到消息。

Second User (two.html) : Sender

FIrst User (one.html) : Receiver

Script form first user: which supposed to get the message

<script type="text/javascript" src="https://api.mesibo.com/mesibo.js"></script>
<script> 
var demo_user_token = 'XXXXXXXXXXXXXXXXXX';
var demo_appid = 'legal.web';

var api = new Mesibo();

api.setListener(new MesiboListener());
api.setAppName(demo_appid);
api.setCredentials(demo_user_token);
api.setAccessToken(demo_user_token);

//api.setDatabase("mesibo");

api.start();


console.log('First User');

function MesiboListener() {
}

MesiboListener.prototype.Mesibo_OnConnectionStatus = function(status, value) {
    console.log("Mesibo_OnConnectionStatus: "  + status);
}

MesiboListener.prototype.Mesibo_OnMessageStatus = function(m) {
    console.log("Mesibo_OnMessageStatus: from "  
            + m.peer + " status: " + m.status);
}

MesiboListener.prototype.Mesibo_OnMessage = function(m, data) {
    console.log("Mesibo_OnMessage: from "  + m.peer);
}

MesiboListener.prototype.Mesibo_OnCall = function(callid, from, video) {
    console.log("Mesibo_onCall: " + (video?"Video":"Voice") + " call from: " + from);
}


</script>

Script from the second user, who send message to the first user using first user's token


<script type="text/javascript" src="https://api.mesibo.com/mesibo.js"></script>

<input type="button" value="Send" onclick="sendTextMessage()" >

<script> 
var demo_user_token = 'XXXXXXXXXXXXXXXXXXX';
var demo_appid = 'legal.web';

var api = new Mesibo();

api.setListener(new MesiboListener());
api.setAppName(demo_appid);
api.setCredentials(demo_user_token);
api.setAccessToken(demo_user_token);

api.start();

console.log('Scond User User');

function MesiboListener() {
}

MesiboListener.prototype.Mesibo_OnConnectionStatus = function(status, value) {
    console.log("Mesibo_OnConnectionStatus: "  + status);
}

MesiboListener.prototype.Mesibo_OnMessageStatus = function(m) {
    console.log("Mesibo_OnMessageStatus: from "  
            + m.peer + " status: " + m.status);
}

MesiboListener.prototype.Mesibo_OnMessage = function(m, data) {
    console.log("Mesibo_OnMessage: from "  + m.peer);
}

function sendTextMessage() {

    let to = "2757b980f05600c48d75f17f6cb0480ed3a91557655dc7d2ebb3f2dc5vaa1cbe86178"
    var profile = api.getProfile(to, 0);
    console.log(profile);
    var id = parseInt(Math.random()*10000);
    profile.sendMessage(id, "this is text message");
}

</script>

为什么要在“to”参数中使用令牌?它应该是地址“USER_2”。请不要在 public 论坛中分享您的代币。

function sendTextMessage() {

    let to = "USER_2"
    var profile = api.getProfile(to, 0);
    console.log(profile);
    var id = parseInt(Math.random()*10000);
    profile.sendMessage(id, "this is text message");
}

参考这里的教程https://mesibo.com/documentation/tutorials/get-started/javascript/