Closed xingguangkuo closed 6 years ago
You have to attach first. For instance, see here: https://github.com/tinode/example-react-js/blob/master/index.html#L4294
var t111 =Tinode.Tinode.getTopic("usrctNBS3OGhFE");
var query = t111.startMetaQuery().withDesc().withSub().withData();
var pub = {"fn":"bob"}; //对方用户名
var priv = ["email:bob@example.com"]; //对方用户邮箱
t111.subscribe(query.build(), {desc: {public: pub, private: priv}});
t111.publish(textMsg, undefined, "text/plain").then(function (ctrl) {
console.info(ctrl);
});
I added subscriptions, but sometimes I occasionally had 409.
All commands are asynchronous. You may wish to wait for the completion of subscribe
before issuing publish
, e.g. subscribe(...).then(...)
When I used a one to one chat, there were the following mistakes based on the subscription Topic.
my code: Tinode.Tinode.publish("usrGq2qpQ0u9ws","1122",undefined,"text/plain") .then(function(ctrl) { console.info(ctrl); }); }).catch(function(err) { // Login or subscription failed, do something. console.info(err); }); error log: tinode.js?723e:873 Uncaught (in promise) Error: Error: must attach first (409) at execPromise (tinode.js?723e:873) at Object.dispatchMessage [as onMessage] (tinode.js?723e:1066) at WebSocket.conn.onmessage (tinode.js?723e:532)
how to solve the problem? thank you