Placeholder-Software / Dissonance

Unity Voice Chat Asset
70 stars 5 forks source link

Voice Chat Not Running From Dedicated Server #115

Closed crydrk closed 5 years ago

crydrk commented 5 years ago

Context

Host communication in the HLAPI demo scene works fine, but running as 'server only' causes server headset to not hear or speak.

Expected Behavior

Server should hear clients, and inspector should show data being sent.

Actual Behavior

Server status shows connected, but no data is transferred.

Steps to Reproduce

Provide a detailed set of steps to reproduce the problem

  1. Import Dissonance
  2. Import HLAPI Integration
  3. Ignore license copy step because just testing
  4. Install Visual Studio 2015 Redist v140, restart
  5. Set Run in Background
  6. Open Demo Scene - set project setting, channel settings, setup Input, as per docs
  7. Observe Host connection working as expected
  8. Observe Server Only connection failing to transmit client or server voice

Your Environment

Include as many relevant details about the environment you experienced the bug in

HLAPI_EditorLog.log

crydrk commented 5 years ago

HLAPI_Client_EditorLog.log

^^ Client log, also running in Editor on a separate computer (this log may have a session where I accidentally clicked server only first, before actually connecting as client)

martindevans commented 5 years ago

Server should hear clients, and inspector should show data being sent.

It sounds to me like you're probably expecting the wrong thing. A dedicated server does not receive/transmit any audio - the primary distinction between a normal server and a dedicated server is that the dedicated server purely does networking.

If you only have one client connected to a dedicated server you won't hear anything (because you can't hear yourself, and a dedicated server can't hear anyone) and you won't see any network traffic (because Dissonance is smart enough not to send voice when no one is listening).

crydrk commented 5 years ago

Ahh I see. I have an installation multiplayer vr game where I'd like the person who's running the game to be able to communicate with the players. Does this mean to use Dissonance I can only do this is the person running the game is a 'host'? If I understand correctly, a host must be both a server and a client.

Trying to make sure I'm using the correct Unity terms here regarding the example netowrking ui : Host being a server as well as a client, and server only being the dedicated server we're discussing. Apologies if I'm misunderstanding.

martindevans commented 5 years ago

Does this mean to use Dissonance I can only do this is the person running the game is a 'host'? If I understand correctly, a host must be both a server and a client.

That's correct. Dissonance always runs in the same mode as the underlying network system. So if HLAPI has been set to run as a dedicated server then Dissonance also starts itself as a dedicated server. If the HLAPI is a host (client and server) then Dissonance starts itself as a host (and creates recording/playback pipelines).

If that's inconvenient it's quite simple to change this behaviour with a single line change to Dissonance. In HlapiCommsNetwork around line 56 you will find this:

if (server && client)
    RunAsHost(Unit.None, Unit.None);
else if (server)
    RunAsDedicatedServer(Unit.None);
else if (client)
    RunAsClient(Unit.None);

This is where Dissonance chooses what mode to run as. You can simple swap RunAsDedicatedServer for RunAsHost and that should work.

crydrk commented 5 years ago

That would be really great! Unfortunately I've tried this fix and I get the following error.

[Dissonance:Network] (22:57:34.683) HlapiClient: Object reference not set to an instance of an object UnityEngine.Debug:LogError(Object) Dissonance.LogMessage:Log() (at Assets/Plugins/Dissonance/Core/Log.cs:66) Dissonance.Logs:SendLogMessage(String, LogLevel) (at Assets/Plugins/Dissonance/Core/Log.cs:95) Dissonance.Log:WriteLog(LogLevel, String) (at Assets/Plugins/Dissonance/Core/Log.cs:178) Dissonance.Log:Error(String) (at Assets/Plugins/Dissonance/Core/Log.cs:410) Dissonance.Networking.BaseClient`3:RunUpdate(DateTime) (at Assets/Plugins/Dissonance/Core/Networking/BaseClient.cs:202) Dissonance.Networking.BaseClient`3:Update() (at Assets/Plugins/Dissonance/Core/Networking/BaseClient.cs:174) Dissonance.Networking.Session:Update() (at Assets/Plugins/Dissonance/Core/Networking/BaseCommsNetwork.cs:159) Dissonance.Networking.BaseCommsNetwork`5:Update() (at Assets/Plugins/Dissonance/Core/Networking/BaseCommsNetwork.cs:327) Dissonance.Integrations.UNet_HLAPI.HlapiCommsNetwork:Update() (at Assets/Dissonance/Integrations/UNet_HLAPI/HlapiCommsNetwork.cs:87)

martindevans commented 5 years ago

Ah with hindsight it was obvious that would happen - this is Dissonance (running a client) trying to use the HLAPI client instance (which is null, because the HLAPI is not running a client). Unfortunately this would be rather difficult to fix within Dissonance.

Since you want host like functionality what is stopping you running your dedicated server as a host instead?

crydrk commented 5 years ago

I see - no worries.

Indeed I've trying to run as a host now as a backup to what we've been talking about, but I'm having troubles keeping the host from spawning its own player. Not sure what to override in NetworkManager to stop that yet. If you know off the top of your head the answer I'd appreciate it, but we've moved well past your responsibility to help me with this. I very much appreciate your quick responses. I can see Dissonance working as host when I speak now, so this will be a good solution once I figure the spawning thing out.

martindevans commented 5 years ago

I'm afraid I don't know much about the player spawning of HLAPI. My knowledge of all the UNet stuff is just the very low level packet based stuff required for VoIP.

Since it sounds like you may be able to work out a solution I'll close this issue, but don't hesitate to re-open it or to post again if you continue to have problems :)

crydrk commented 5 years ago

Thanks again for all your help! I managed to get it working.

(hopefully this comment doesn't reopen the issue, sorry if it does) For any future googlers in my situation: I solved it by setting a bool if it's host, and then overriding NetworkManager.OnClientConnect to simply return if not a real client.