Listener: A Novel Method for Implementing StageLinq #21
honusz
started this conversation in
Show and tell
Replies: 2 comments 4 replies
-
@honusz AMAZING dude!!! When I get some free cycles this month, I'm definitely gonna dive into this and see how it works! |
Beta Was this translation helpful? Give feedback.
2 replies
-
@honusz - This is so awesome! I hope to one day help get the go-stagelinq library providing Stagelinq services also -- especially if you find out we can do interesting stuff like act as a remote source for a player! :) |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi everyone, I'm very excited to share something I've been working on for a while. I'm curious to know what you all think.
https://github.com/honusz/StageLinq/tree/Listener
StageLinq - Listener Proof of Concept
Description
This branch demonstrates a novel way of handling connections with devices and their services on the StageLinq network.
Rather than searching out devices via discovery, we are able to have devices initiate connections to the library. As demonstrated, this approach:
Greatly reduces complexity.
Speeds up the connection & initialization process (almost every sleep() call has been eliminated without and affect thus far).
Handles disconnection and reconnection of devices gracefully and simply.
Allows connections from devices we couldn't use previously (i.e. x1800/x1850 mixers).
Method Summary
Instantiate a net.Server for each service we wish to implement.
Write a DiscoveryMessage which includes the port on which the Discovery service is listening, and announce ourselves on UDP port 51337.
StageLinq devices on the network will initiate a connection to the Directory service, and send a Service Request (0x2).
Reply to each device with a Service Announcement (0x0) for each of the services we offer and the port we are listening to them on.
If a device implements that service it will initiate a connection, sending a Service Announcement (0x0), a Network String with the name of the service, and the port it is using.
The connection to this Device-Service is now open, and we can use it as we normally would.
If a connection is lost to a device, it will simply reconnect.
Additional Notes on the Listener Method
The Directory service is the only one which is required as it is the initial connection endpoint for remote devices.
Only tokens of a specific structure seem to work, otherwise devices won't initiate a connection. One requirement seems to be that they start with
0xFF FF FF FF FF FF
, but some more research into this is needed.Implementing Selected Services
We can choose which services to implement in the initialize() method in StageLinqDevices.ts
Other Changes Implemented in Listener
When a device is shutdown, it sends a Disconnection message (0x9) to connected FileTransfer service.
Network Device has been eliminated.
Created a DeviceId class, to assist handling deviceIds.
Created some other type definitions (IpAddressPort) to better communicate what properties are expecting.
Instances of Service have a new abstract method, parseServiceData. This is just because ServiceAnnouncement messages on StateMap and FileTransfer were causing some headache, and needed to be parsed separately.
FileTransfer Unknown0 message is used to trigger getSources. See notes in code.
To Be Implemented / Possibilities
EventEmitter stuff isn't fully implemented yet, with a few exceptions (those needed for FileTransfer)
FileTransfer has only been tested with DB.
Some methods from Database.ts have been moved to FileTransfer. This isn't intended to be permanent, it was just to allow a demonstration of downloading a DB.
TimeSyc.ts is in the project, but should be disregarded for now.
We could possibly eliminate StageLinqDevices, as this step is no longer really necessary. Multiple devices are handled by single instances of each service.
StageLinqListener and Announce could be reworked into a single class. Presently all StageLinqListener is doing is adding and updating a list of announced devices (StageLinqDevices.peers).
Compatibility Notes
@MarByteBeep @icedream @chrisle @mhite @dzelionis
Beta Was this translation helpful? Give feedback.
All reactions