JSPM

com.adrenak.univoice.mirrornetwork

1.0.0
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 9
    • Score
      100M100P100Q54256F
    • License MIT

    ChatroomNetwork implementation for UniVoice based on Mirror by vis2k.

    Package Exports

      This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (com.adrenak.univoice.mirrornetwork) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

      Readme

      UniVoice Mirror Network

      This repository contains the Mirror based implementation of the IChatroomNetwork interface in UniVoice

      Dependencies

      com.adrenak.univoice@3.0.0

      The UniVoice version this implementation uses.

      com.adrenak.brw@1.0.1

      A simple byte array reader and writer it uses to send and receive messages

      Installation

      1. Ensure the UniVoice package has been imported in your project.
      2. Import this package.
      3. 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.
      4. Add UNIVOICE_MIRROR to your projects Scripting Define Symbols to enable the UniVoiceMirrorNetwork 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 on NetworkClient and NetworkServer to get messages.

      You create a ChatroomAgent with

      1. an instance of UniVoiceMirrorNetwork
      2. the audio output implementation of your choice. You're likely looking for AudioSourceOutput which plays audio using Unity's AudioSource
      3. 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.