#Networking Issue

1 messages · Page 1 of 1 (latest)

honest zealot
#
public struct SendFile : NetworkMessage
{
    public byte[] imageBytes;
    public string imageName;
}
public class FileLoader : MonoBehaviour
{
    [SerializeField] private FileManager manager = null;
    [SerializeField] private Texture2D loadedImage = null;

    private void Start()
    {
        if (!NetworkClient.active) return;

        NetworkClient.RegisterHandler<SendFile>(OnSendFile);
    }

    private void OnSendFile(NetworkConnection conn, SendFile file)
    {

    }
}```

Hello! I'm following Dapper Dino's multiplayer messaging tutorial, and I've been getting this error:
```error CS1503: Argument 1: cannot convert from 'method group' to 'Action<SendFile>'```
I've been following the tutorial closely and ran into this issue which I'm unsure of how to solve.

NetworkClient.RegisterHandler<SendFile>(OnSendFile);```
This line is causing the problem, but I have no idea how to fix it since I'm relatively new to networking. Any ideas?

summer crater
#

Going by just the error message, it appears that OnSendFile needs to only take a parameter of type T, as RegisterHandler<T>() expects an Action<T> as parameter.

#

I would suggest to not follow two-year-old tutorials, especially on stuff like multiplayer frameworks, and even more so without consulting the documentation yourself to see what might have changed.

honest zealot
#

ah i see, thank you!

honest zealot