custom node.js server - straighforward?
I'm looking to implement Dissonance on the client side in Unity, but with clients connecting to each other through a custom p2p networking stack that's got a node.js backend.
Is it correct that Dissonance can collect/sample and encode the audio within Unity and generate bytes for a packet? So then all I'd have to do is get those packets to the other player(s) and use Dissonance to decode and play them? Our data connection is working quite well, but figuring out how to implement all the client-side interfaces in Dissonance for this use case is challenging.
Has anyone done anything like what I'm proposing, or has any guidance?
Thanks!
Posted Mar 23, 2021, 2:55 AM UTC
12
Hi jadware,
I wouldn't call this straightforward, but it is possible.
Dissonance has some base classes built in for building custom network integrations (BaseCommsNetwork/BaseClient/BaseServer). On the Unity/Client side of things you need to implement classes extending these as normal (docs), sending and receiving from the client to the NodeJS server. Of course your implementation of BaseServer can just do nothing (throw
NotSupportedExceptioneverywhere) because you'll never run a server in the client.The difficult bit is the server side. You'll need to reimplement everything that BaseServer does for you in Javascript:
Assets/Plugins/Dissonance/Core/Networking/PacketWriter.csandAssets/Plugins/Dissonance/Core/Networking/PacketReader.cs)Assets/Plugins/Dissonance/Core/Networking/BaseServer.cstheNetworkReceivedPacketmethod).Ultimately the server just does three things:
HandshakeRequestpacket.ClientStateandDeltaChannelStatepackets.ServerRelayReliableandServerRelayUnreliablepackets.excellent, thanks, will dig in