Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ public static bool Send(int hostId, int connectionId, int channelId, byte[] buff
return UnityEngine.Networking.NetworkTransport.Send(hostId, s_RelayConnectionId, channelId, buffer, size, out error);
}

#if !UNITY_WEBGL
public static bool QueueMessageForSending(int hostId, int connectionId, int channelId, byte[] buffer, int size, out byte error)
{
if (!Enabled)
Expand Down Expand Up @@ -350,6 +351,7 @@ public static bool SendQueuedMessages(int hostId, int connectionId, out byte err

return UnityEngine.Networking.NetworkTransport.SendQueuedMessages(hostId, s_RelayConnectionId, out error);
}
#endif

public static NetworkEventType ReceiveFromHost(int hostId, out int connectionId, out int channelId, byte[] buffer, int bufferSize, out int receivedSize, out byte error)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using MLAPI.Logging;
using MLAPI.Profiling;
using MLAPI.Transports.Tasks;
using UnityEngine.Assertions;
using UnityEngine;
using UnityEngine.Networking;

namespace MLAPI.Transports.UNET
Expand Down Expand Up @@ -80,6 +80,9 @@ protected void LateUpdate()
{
if (UnityEngine.Networking.NetworkTransport.IsStarted && MessageSendMode == SendMode.Queued)
{
#if UNITY_WEBGL

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about throwing an exception? Otherwise looks like it will just throw an error and then do nothing.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, since we are following the pattern of throwing exceptions...but the weird part of this is that it will be in a browser... so haven't done a bunch of that...but it could be that the best you can do under that scenario is to just log the issue. Really, we need to have a "internal MLAPI dialog box" that can display critical errors for users...so we know they will see it no matter what.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't. It literately doesn't compile because those methods gets stripped for WebGL.

Debug.LogError("Cannot use queued sending mode for WebGL");
#else
if (NetworkManager.Singleton.IsServer)
{
for (int i = 0; i < NetworkManager.Singleton.ConnectedClientsList.Count; i++)
Expand All @@ -91,6 +94,7 @@ protected void LateUpdate()
{
SendQueued(NetworkManager.Singleton.LocalClientId);
}
#endif
}
}

Expand Down Expand Up @@ -147,15 +151,19 @@ public override void Send(ulong clientId, ArraySegment<byte> data, NetworkChanne

if (MessageSendMode == SendMode.Queued)
{
#if UNITY_WEBGL
Debug.LogError("Cannot use queued sending mode for WebGL");
#else
RelayTransport.QueueMessageForSending(hostId, connectionId, channelId, buffer, data.Count, out byte error);
#endif
}
else
{
RelayTransport.Send(hostId, connectionId, channelId, buffer, data.Count, out byte error);
}
}


#if !UNITY_WEBGL
public void SendQueued(ulong clientId)
{
if (ProfilerEnabled)
Expand All @@ -167,13 +175,14 @@ public void SendQueued(ulong clientId)

RelayTransport.SendQueuedMessages(hostId, connectionId, out byte error);
}
#endif

public override NetworkEvent PollEvent(out ulong clientId, out NetworkChannel networkChannel, out ArraySegment<byte> payload, out float receiveTime)
{
var eventType = RelayTransport.Receive(out int hostId, out int connectionId, out int channelId, m_MessageBuffer, m_MessageBuffer.Length, out int receivedSize, out byte error);

clientId = GetMLAPIClientId((byte)hostId, (ushort)connectionId, false);
receiveTime = UnityEngine.Time.realtimeSinceStartup;
receiveTime = Time.realtimeSinceStartup;

var networkError = (NetworkError)error;
if (networkError == NetworkError.MessageToLong)
Expand Down
8 changes: 0 additions & 8 deletions testproject/Assets/Scripts.meta

This file was deleted.