added sender id to custom message type, added trycatch to custom message handler

main
Anton Franzluebbers 2022-01-30 17:25:11 -05:00
parent eaf80a2dff
commit d186dfdf9b
2 changed files with 10 additions and 2 deletions

View File

@ -81,7 +81,7 @@ namespace VelNet
public static Action<RoomsMessage> RoomsReceived; public static Action<RoomsMessage> RoomsReceived;
public static Action<Message> MessageReceived; public static Action<Message> MessageReceived;
public static Action<byte[]> CustomMessageReceived; public static Action<int, byte[]> CustomMessageReceived;
#endregion #endregion

View File

@ -137,7 +137,15 @@ namespace VelNet
case VelNetManager.MessageType.Custom: // custom packets case VelNetManager.MessageType.Custom: // custom packets
{ {
int len = reader.ReadInt32(); int len = reader.ReadInt32();
VelNetManager.CustomMessageReceived?.Invoke(reader.ReadBytes(len)); try
{
VelNetManager.CustomMessageReceived?.Invoke(m.senderId, reader.ReadBytes(len));
}
catch (Exception e)
{
Debug.LogError(e);
}
break; break;
} }
default: default: