Copy link to clipboard
Copied
I am hoping someone can point me in the right direction. I have a CF2021 Server which runs a Node.js websocket server and CF pages (via javascript) as a client. Messages from user to user work as expected, so no issue there.
This CF Server also has a custom API built using CFML that handles and routes inbound SMS messages. My question is; what would be the best way to send the SMS message (by now its json) to the Node.js websocket to it can send it to the user(s).
I tried using the same javascript that the browser client uses, but it appears that the CFML API script is "browser-less", so that doesn't work, or should it?
I thought something like Apache Groovy may be the solution, but I am having difficulties with any websocket broadcast example I have found.
Any suggestions would be greatly appreciated.
thanks in advance
Copy link to clipboard
Copied
Messages from user to user work as expected, so no issue there.
By @artiem51422106
If I were you I would then find a way to make the CFML API emulate a user. Perhaps cfclient might be handy for converting CFML to Javascript.
Apache Groovy, like CFML, is server-side. So, were you to use Groovy, I would expect you to face the same challenges as you do with CFML.
Copy link to clipboard
Copied
BKBK,
thanks for your reply, this has been days of trial an error. I looked into CFCLIENT and tried a few things, but I wasn't getting very far. I am most likely not doing it correctly, but it does not seem to load the jquery module which is needed to make the websocket connection within the CFCLIENT tag.
I thought I was getting somewhere with the groovy code, as I was able to implement some groovy code (java) during the CFML template process on the server, but could no get any websocket code to run without errors, but I suspect that may be due to how I am invoking the groovy file.
To my client - this should be an easy thing to do - CFML templates do the API processing and at some point, send a JSON structure to the running node.js websocket running on the same server. Finding a way to "emulate a websocket user" seems to be the whole issue unfortunately. Thanks again for your response.
Copy link to clipboard
Copied
If the Javacript way is not feasible, there is yet another possibility. You could try creating a websocket object in ColdFusion, and using it to subscribe to a websocket channel on Node JS. Under the covers, ColdFusion would then convert the object into Javascript anyway.