Lucee Websocket Exention 3.0.0.20-Snapshot broken?

I have posted quite a few bit of log information on this thread:

And found that restarting Lucee twice in a row will get the websocket to connect and return a message, then close after 60 seconds as noted here:

However I am either quite ignorant/clueless on how this websocket works or it is broken.

My 1st issue is, I have no way of figuring out who just connected to my websocket. I was hoping to get some guidance from the wsclient argument, but when I send that back as JSON data, it empty, so I do not know what parts there are to look at.

When I try to store the wsclient into a Session, or Application Scope, it does not modify the variable.

I tried to read the Session Scope and the websocket would disconnect.

I see I can use WebsocketInfo() and run thru the instances, but I still do not know how I would compare that to a list because I do not know who just connected. I thought for a moment I could add them to an Application list, but when I have more then 1 person in the list, I still do not know how I can identify who just connected if all I can do is loop through the websocketInfo() instance of connections.

My code is pretty much a copy of the examples
In Application.cfc OnApplicationStart() I set

Application.thisClient = "";

websocket.cfc

component hint="websockets" 
{

    public static function onFirstOpen( wsclients ) 
    {
        static.wsclients = arguments.wsclients;
        Session.thisClient = 'hello';
        Application.thisClient = 'merpsies';
    }

    function onOpen( wsclient )
    {
        //var thisClient = Session.sessionObj.getUserId(); //this will close the connection 
        Application.thisClient = 'Oh my';
        var thisAppClient = Application.thisClient;
        //static.wsclients.broadcast("There are now #static.wsclients.size()# connections");
        //var wsInfo = websocketInfo(false);

        //var wsInstances = wsInfo.instances;

        arguments.wsclient.send( Application.thisClient );
    }

    function onOpenAsync( wsclient )
    {

    }

    function onMessage( wsclient, message )
    {

    }

    function onClose( wsclient, reasonPhrase )
    {

    }

    function onError( wsclient, cfcatch )
    {

    }

    public static function onLastClose()
    {

    }
}

My test.cfm

<!--- "directory":"{lucee-config}/websockets/",  --->
<cfset thisUUID = CreateUUID() >
<!---
<cfset Application.thisClient = 'new' />

<cfset Session.thisClient = "Me" /> ---> 
<script type="text/javascript">
const socket = new WebSocket("wss://dev.example.com:446/ws/websocket?uuid=<cfoutput>#thisUUID#</cfoutput>");

socket.onopen = function (evt) {
  console.log("Connected");
  socket.send("Hello, Lucee Extension!");
};

socket.onmessage = function (event) {
  console.log("Received:", event.data);
};

socket.onclose = function (evt) {
  console.log("Connection closed");
};

socket.onerror = function (error) {
  console.error("WebSocket error:", error);
};
</script>

<cfdump var="#Session.thisClient#" />
<cfdump var="#Application.thisClient#" />
<cfdump var="#Session.sessionObj.getUserId()#" />

A page setup so I can look at what was altered

<cfdump var="#websocketInfo()#" />

<cfdump var="#Session.thisClient#" />
<cfdump var="#Application.thisClient#" />

In the onOpen() section, you can see I set the Application.thisClient to “Oh my” And the websocket will recieve “Oh my” but if I refresh the page I setup to look at the variables, it is still set to “”.

So even if I knew how to pull the id from the wsclient onOpen() I have no way of saving it to the application scope.

What am I missing? Any direction is much appreciated as I am now scratching my head.

While I was proof reading my above rant, I had an idea on how to identify the sender onOpen(). I had to send a message right after onOpen() with information I loaded into a database since I cannot modify or it seems even to access Application Scope.

With this, and the example code

var wsInfo = websocketInfo(false);
if ( !wsInfo.instances.len() )
    return;

var wsInstances = wsInfo.instances;

var item = getRedisData();
var stItem = deserializeJSON( item );
for ( var wsI in wsInstances ) {
    if ( GetMetadata( wsI.component ).name == 'test' && wsI.component.hasRole( stItem.data.role ) ) {
        wsI.component.sendMessage( item );
    }
}

I was able to painstakingly pick thru what I needed to do.

Can I put in a request for an update to allow access to the Application Scope? I cannot use GetApplicationSettings().defaultdatasource inside the websocket CFC so all the datasource names are hardcoded at the moment. Not the best way for this to work, as now when I move to production I have to edit all the db entries.