Open lamlnt opened 4 months ago
Rather than add an additional interface type, could you use include some metadata in the type OR use a different type for the server vs client? Might be simpler than getting into the internals.
//Message with metadata
public struct GenericMessage
{
public bool isFromServer { get; set; }
public bool isFromClient { get; set; }
//other data
}
//separate types for server vs client
// using structs vs classes, though same effect could be done via inheritance
public interface IGenericMessage
{
//other data
}
public struct ServerGenericMessage : IGenericMessage
{
}
public struct ClientGenericMessage : IGenericMessage
{
}
Thanks for the reply @WillNichols726 ! We're actually using these methods right now in our projects. However, it quickly becomes tedious and verbose to add so many data structures. Plus, I was looking for a customized solution where I do not need to declare the IsServer bool/validate IsServer everytime I need to publish/receive a message! (oops wrong account 😅 )
I'm working on a network multiplayer game and during development. we would run both server and client instances on the editor. One problem we run into frquently is to distinguish whether the messages come from client or the server, and where they are received.
Is there a way to extend the available interfaces to adapt this?