简体   繁体   中英

Error when sending message with realtime.co - Boolean is not a function

I am using realtime.co for realtime messaging in my .NET 4.5/Javascript webapp.

I created a connection using the code:

xRTML.ready(function () {

xRTML.Config.debug = true;


globalRealtimeConnectionId = generateUUID();

globalRealtimeToken =  getRealtimeToken();

globalMyConnection = xRTML.ConnectionManager.create(
        {
            id: globalRealtimeConnectionId,
            appkey: 'xxxx',
            authToken: globalRealtimeToken, // insert token
            url: 'http://ortc-developers.realtime.co/server/2.1'
        });


globalMyConnection.bind(
{
    // When we get a message, process it
    message: function (e) {

        var user = e.message; // the use that just joined

    }
}); 

globalMyConnection.active = true;
});

On the server I gave permissions to "main:*" (all sub channels) and returned a token.

When I send a message to the user from the server using the following code:

       OrtcClient client = (OrtcClient)Application["realtime"]; // get reference to client, which initialized in global.asax
        client.Send(channel, user); // send message 

user is a string with the username, channel is the channel name (eg main:12_323_34_. I get the following error in xrtml-custom-3.2.0-min.js:1

Uncaught TypeError: boolean is not a function xrtml-custom-3.2.0-min.js:1
c.Connection.process
(anonymous function)
 f.proxy
 IbtRealTimeSJ.d.sockjs.d.sockjs.onmessage
 x.dispatchEvent
 m._dispatchMessage
 m._didMessage
 m.websocket.d.ws.onmessage

From what I can tell, the client is subscribed because it triggers something when a message is sent to it from the server. But I can't understand the source of the error. Because of the error, the function binded to "message:" is not triggered.

For debugging purposes, if I were you, I would include the non-minified version so you can see exactly what function is causing the error. Once you've done that, it should be easier to track down.

One other quick note is when making RESTful calls you should try to do this in the back end so your api key is not exposed to the public. This would obviously only be an issue when you are creating a public facing website, so if this is an organizational (internal) application you can disregard.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM