Capture messages received from the websocket server

I am using the same method to connect to the websocket server as here https://cran.r-project.org/web/packages/websocket/readme/README.html

However, the output has the following structure using ws$connect() function

> ws$connect()
Connection opened
send login request

Got Message [{"ID":1,"Type":"Refresh","Domain":"Login","Key":{"Name":"XXXX","Elements":{"AllowSuspectData":1,"ApplicationId":"XXX","ApplicationName":"XXX","AuthenticationErrorCode":XXX,
"AuthenticationErrorText":{"Type":"AsciiString","Data":null},"AuthenticationTTReissue":XXX,"Position":"XXX","ProvidePermissionExpressions":1,"ProvidePermissionProfile":0,"SingleOpen":1,"SupportEnhancedSymbolList":1,"SupportOMMPost":1,"SupportPauseResume":0,"SupportStandby":0,"SupportBatchRequests":7,"SupportViewRequests":1,"SupportOptimizedPauseResume":0}},"State":{"Stream":"Open","Data":"Ok","Text":"Login accepted by host XXX"},"Elements":{"PingTimeout":XX,"MaxMsgSize":XXX}}]

#here starts part, which is needed to be saved (Price1-3)
Single Message   
{"ID":2,"Key":{"Name":"XXX"},"View":["Price1","Price2","Price3"]}
Got Message [{"ID":2,"Type":"Refresh","Key":{"Service":"XXX","Name":"XXX"},"State":{"Stream":"Open","Data":"Ok","Text":"*All is well"},"Qos":{"Timeliness":"XXX","Rate":"XXX"},"PermData":"XXX","SeqNumber":4000,"Fields":{"Price1":16.255,"Price2":16.345,"Price3":5}}] 

The $onMessage() function is following (with # I marked the lines I added, source: https://github.com/Refinitiv/websocket-api/blob/master/Applications/Examples/R/market_price_authentication.R)

test1<-NULL
ws$onMessage(function(event) {
 
 cat("Got Message",event$data,"\n")
 jsonresp <- fromJSON(event$data, simplifyDataFrame=FALSE)
 #test1<-event$data  
 #event$data
 
 
 for (singleMsg in jsonresp){
   process_message(singleMsg) # Single Message send pong
   
 }  
 
}
)

There should be something added to ws$onMessage in order to save the output, preferably dt/or csv. How can I save the output of this function?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.