UNET can you pass List data types via messages?

I am passing a List from the server to the client, the UNET listener on the client is being triggers, if I pass a message with an int and a List, the int value is correct but the List is null.

Are List types supported in UNET messages?

EG send code (not passing number in this example):

    var response = new MasterMsgTypes.DataServerReturnListOfGameServersMessage
    {
        GameServers = gameServers
    };

    netMsg.conn.Send(MasterMsgTypes.DataServerReturnListOfGameServersId, response);

EG of receive code:

void OnDataServerReturnListOfGameServers(NetworkMessage netMsg)
{
    var msg = netMsg.ReadMessage<MasterMsgTypes.DataServerReturnListOfGameServersMessage>();

    LobbyManager.Instance.GameServers = msg.GameServers;
}

Even though the send response contains a List of class values, the receiving netMsg has a null value in msg.GameServers

It may be the List is being initiated with blank values as I had a similar issue when using DLL’s with the message ID and structures

thanks!

I’ve learnt through my use of uNet that passing data on packets practically only allows the most primitive types to be sent - that means strings, ints, bools, floats, chars, anything that’s basically a mostly basic data type. Things such as GameObject and other Unity classes are best off using UnityWriter or UnityReader - however, they also have their own problems, and generally don’t work all the time in my experience.

The best workaround I’ve figured out it to break the object down into the primitive types and then build it back up after the message has been sent.

Whatever a GameServer is - break it down into basic data types, send it across, then rebuild it. It’s less efficient, but for whatever reason, I can’t find nor think of any other way around it.

I’m not currently using lists directly, but a decent workaround would be to simply send a comma delimited string, and then use system.convert to convert the value to whatever you need.