cancel
Showing results for 
Search instead for 
Did you mean: 

Consuming PCo WebSocket using SAPUI5

Former Member
0 Kudos

Hi there,

I've read a lot about PCo and its ability to provide WebSockets. There is a document about configuring PIC consuming the PCo data here:

The SSCE is able to use the WebSockets provided by PCo. However, how do I consume the WebSockets via a SAPUI5 application I wrote myself? Is there a help document for this issue?

Regards

Tobias

Accepted Solutions (1)

Accepted Solutions (1)

Former Member

Hi Tobias,

you could simply add an update call to the model you use for the MVC:


mockWs.onmessage = function(event) {

    // retrieve the message and put it into a JSONModel

    var jsonData = JSON.parse(event.data);

   oModel.setProperty("/some", jQuery.merge([jsonData], oModel.getProperty("/some")));

   oModel.refresh(/* force */ true);

};


See this gist for a working example: Example Websocket usage with Sapui5

Am I missing something? I guess you are looking for something a bit more built-in.


Regards,

M.

(... hm, I wonder why the syntax highlighting is broken ...)

Former Member
0 Kudos

Thanks Martin, this is a very good example, but using standard JavaScript WebSocket. I thought about using a SAPUI5 class like SapPcpWebSocket, see here:

SAPUI5 SDK - Demo Kit

Anyway, using standard WebSocket doesn't seem to be that complex. Thanks for your solution.

Regards

Tobias

Answers (0)