Oh damn, that’s going to be a tough challenge. I hope your networking and serialization skills are good! This is a solvable problem, but it’s going to take you a really long time.
Basically, what you have to do is manually maintain synchronized game states between a Unity based game and an Unreal based game and have a universal way for games on both engines to talk to each other. To do that, you’ll have to do the following:
Choose a networking protocol (TCP/IP or UDP) and encode your data packets for that protocol. You’ll have to structure your data to be engine agnostic, so if Unity or Unreal wants to wrap network data in an encapsulation layer, you’re going to have to strip that engine metadata away.
You’ll need to decide on a universal serialization schematic. Your game objects will need to be serialized and deserialized exactly the same way on both Unity and Unreal. You’ll also need to have a metadata scheme.
Your server is going to need to know what engine platform connected clients are using so that you can send properly formatted network data.
If any section of server side or client side code changes on either engine, you will need to update your net code. Otherwise, you lose game sync.
You’re almost certainly going to have to dive into the engine code or create your own networking plugin.
Seriously though… this is going to be a long and painful effort. There are no silver bullets; There are no easy solutions. As amber said, “Why would you doing this?”. What difference does it make to the end user whether they are using a UE4 game client or Unity game client? Just pick one and stick with it.
PS. Just to illustrate that it’s 100% possible, look at the HTTP protocol, browser clients and web servers. You can have different web servers and different browsers, but what is used on either end doesn’t matter because both browsers and servers use the HTTP protocol which is a universal standard. There isn’t an HTTP equivalent for game engines, so you’ll have to create your own protocol and wrap it in TCP/IP.