I am using below code and when i am calling onMessageRender() function, so it says "this is not a function"
request = new Atmosphere.AtmosphereRequest(); // Global Function
Calling below code in ngONinIt
this.createSSE();
//Main function
createSSE(){ this.request.onMessage = function (response) {
console.log('request.onMessage trigger');
try {
let jsonData = JSON.parse(message);
console.log('Normal Message JSON this.request.util', jsonData);
this.onMessageRender();
}catch (e) {
console.log('Error in websocket onmessage: ', e);
return;
} }
Created below function globally
onMessageRender(){
}
Please let me know if you need more information. Thanks!
Assuming this is an Angular/typescript question,
if
createSSEis declared as part of an Angular module, and ifonMessageRender()is a global function which is not declared as part of an Angular module, callingonMessageRender()should be withoutthis, asonMessageRender()may not be part of the same object thatcreateSSEis declared.If
onMessageRender()is indeed part of the same object, I think more detail is required to answer your question.