com.adrenak.univoice.mirrornetwork
v1.0.0
Published
ChatroomNetwork implementation for UniVoice based on Mirror by vis2k.
Downloads
36
Maintainers
Readme
UniVoice Mirror Network
This repository contains the Mirror based implementation of the IChatroomNetwork interface in UniVoice
Dependencies
[email protected]
The UniVoice version this implementation uses.
[email protected]
A simple byte array reader and writer it uses to send and receive messages
Installation
- Ensure the UniVoice package has been imported in your project.
- Import this package.
- Import Mirror. This package was last tested with Mirror version 87.1.7. The Mirror APIs used don't tend to change much, so breaking changes should be minimal.
- Add
UNIVOICE_MIRROR
to your projects Scripting Define Symbols to enable theUniVoiceMirrorNetwork
class.
How it works & how to use
The UniVoiceMirrorNetwork
class is incapable of hosting, joining, closing and leaving a chatroom by itself. Tt just listens to and uses your Mirror server/client. At the root of it, it just calls:
NetworkServer.SendToAll
for the server to broadcast messages to the peers.NetworkClient.Send
for the peers to send their audio to the server/host.- Connection & Disconnection events of the Client & Server using
NetworkManager.single.transport
RegisterHandler
onNetworkClient
andNetworkServer
to get messages.
You create a ChatroomAgent with
- an instance of
UniVoiceMirrorNetwork
- the audio output implementation of your choice. You're likely looking for AudioSourceOutput which plays audio using Unity's AudioSource
- the factory method of an audio input implementation of your choice. Again, you're likely looking for UniMicInput which uses UniMic, a wrapper over Unity's
Microphone
class to capture audio from the microphone. This could look like this:
var chatroomAgent = new ChatroomAgent (
new UniVoiceMirrorNetwork(),
new UniVoiceUniMicInput(0, 8000, 50),
new UniVoiceAudioSourceOutput.Factory()
);
That's it! When you create of join a server/host using Mirror, the audio chat will be initialized.
If you're looking for a lighter network, maybe if you're not using Mirror and just want WLAN audio chat, try UniVoice-Telepathy-Network based on Telepathy by vis2k
Notes
- This network implementation has only been tested with 1 server + 2 clients. A deployment on EdgeGap (cloud) worked just fine. It's not been used in production so far, although two parties have shown interest in doing so. Due to this upcoming improvements are expected and I'll try to keep them non breaking.
- You would want to use some sort of UDP transport in Mirror. There is usually some sort of a packet size limit, for example, Kcp (packaged with Mirror) has a limit of 1194 bytes. Adjust your UniVoiceMicInput constructor parameters accordingly.
Contact
The developer Vatsal Ambastha can be reached at the following links:
website
linkedin
github
twitter
Discord server
UniVoice has been used by games, apps, as well as research projects. Commercial development and consultation can be arranged, although it's very much subject to availability and schedule.