Closed daveseah closed 4 months ago
Confirmed that this works as described. Confirmed that app still runs.
Should I be converting the UDATA calls in Net.Create to EP calls?
(Note minor edit: The "2. TEST UDS and WSS CLIENTS" call should be ur net client
not ur net clients
The new URSYS is not a replacement for UNISYS in NetCreate, as it uses a different internal system and is incompatible.
This PR adds the rewritten URNET messaging system upon which all our apps rely on to talk to each other. It now supports the following communications interfaces:
It should be extensible to other communications interfaces such as MQTT. Additionally, this modular rewrite opens up several possibilities:
This PR is ready for alpha testing. It does NOT impact NetCreate's current operation, as URSYS is designed to be a standalone modular system with its own modern build tools.
Known Issues
netcreate-itest.code-workspace
file has the terminal profile set as:"terminal.integrated.defaultProfile.osx": "x86 macos"
...which may interfere with some systems. Change it togeneric macos
if you have that problem on Intel macs.@ursys/core
in the naming of functions and modules, so if you've written a new addon in_ur_addons
that relies on it you'll have to find the new name. Notably, theFILES
module has been renamed toFILE
.npm run dev
PR Feature Testing
0. INITIALIZING FOR TEST
.code-workspace
file.npm ci
This will install any new packages
1. LAUNCH ALL THE SERVERS
In the terminal window, type the following:
cd _ur
ur net start
Your terminal window will look something like this:![image](https://github.com/netcreateorg/netcreate-itest/assets/2048828/31b9f7c0-0ce5-4799-bb25-96b93ab632ee)
Three different servers have started:
2. TEST UDS and WSS CLIENTS
Now you'll open a second terminal window to run the client tests for UDS and WSS.
cd _ur
againur net client
This will run a series of URNET message tests. The output in the second terminal will look like this:![image](https://github.com/netcreateorg/netcreate-itest/assets/2048828/cb082341-19b3-4f17-8013-7f2c90e94568)
You'll also see that there are connection messages at the bottom of the first terminal window:![image](https://github.com/netcreateorg/netcreate-itest/assets/2048828/0f5ae286-c8e9-46d8-ba5d-7a497bb60c1b)
3. TEST HTTP CLIENT
Now switch to your Chrome web browser and open two tabs.
http://localhost:8080
Command-Option-J
to open the Javascript consoleYou'll see output that looks something like this:![image](https://github.com/netcreateorg/netcreate-itest/assets/2048828/24be9ace-9893-4c3c-9b5f-1c6fcc7b9d4b)
4. SHUTDOWN ALL SERVERS
If there is a server crash, using this command in any available VSCODE terminal window will clean things up.
_ur
directoryur net stop
You'll see this in the terminal window you just typed in:![image](https://github.com/netcreateorg/netcreate-itest/assets/2048828/a43f0b7f-b20a-41bb-8ea4-07cf3c674e15)
You'll see a number of shutdown messages in the terminal window where you originally issued the![image](https://github.com/netcreateorg/netcreate-itest/assets/2048828/a685168f-65c6-401e-864f-3b6a8faab7f8)
ur net start
command:5. SHUTDOWN ALL SERVERS (ALTERNATE)
Alternatively, you can also click in the first VSCODE terminal window by pressing
CTRL-C
to kill theur net start
process._ur
directoryur net stop
just to make sure that there's no servers runningur net start
to start them all up againCTRL-C
The SIGINT is sent to the process, which shuts down all the child processes gracefully (I hope):![image](https://github.com/netcreateorg/netcreate-itest/assets/2048828/ece750e9-3126-430a-baa9-23b75dfacb7f)
Technical Details
The
net
addon is a modular version of URSYS messaging (aka URNET), which is used to implement our asynchronous data passing between multiple webapps by using the server as the messaging hub. It's similar to other message-based systems like MQTT except that URNET provides a transaction call that returns data.URNET is one of the key pillars of our web application operations, allowing programmers without experience in network asynchronous programming to work with our data. URNET is the basis for our controllers, rendering system, and coordination between web applications.
URNET Refresher
URNET Improvements
Old versions of URNET were delicately coded in Javascript, updated over four different projects over the past 10 years, and it was difficult to "reason" about. The new modular version of URNET is written in Typescript and removes many confusing structures. It also combining many intertwined modules of the old system into three new classes:
Because of the abstraction of
NetSocket
, to implement a new server type uses very similar code.Here is the relevant fragment of the WebSocket Server on NodeJS (using the
ws
library):And this is the fragment establishing client connection, also using the NetEndpoint and NetSocket classes:
In particular, these are the lines that are the bridge between the underlying socket tech and NetEndpoint:
For comparison, here are the same lines that are used in the Unix Domain Socket (UDS) version, which uses slightly different semantics (e.g.
write
instead ofsend
) than ws WebSocketsURNET Protocol Handshaking
The new version of the URNET protocol now has an official way to authenticate and register client details, as well as a new declare for dynamically-changing aspects of Endpoints. These are special NetPacket types that are recognized by Endpoints configured as a server.
When a client connects to a server, the following steps are undertaken by the client:
EP.connectAsClient(client_sock, auth)
which sends an authentication packet to the server. On connection, the client now as an address but it is not yet able to send/receive messages.EP.registerClient(info)
to define what kind of client it is. After this step, the client is considered to to be connected to URNET and can send/receive dataEP.clientDeclare({msg_list})
to upload what messages it can receive. The server updates this information whenever it is received, so clients can change their message lists.Previously, there was no formal system for managing authentication and client registration, and it is now baked-into the connection logic. All other services can be implemented using regular messaging.
Short Term Directions
@ursys/addon
to@ursys/core
Long Term Directions
Additional Documentation
See the WIKI hosted on the standalone repo for the URSYS library. This is a work in progress.