Photon master client as dedicated server?

So I made a shooter game with the master client structure and everything works fine, but now I’m trying to create a dedicated server where all clients simply join without anyone being the master client. So basically the server creates a persisten room and everyone else can join and leave.

I downloaded the server SDK and got it to run self hosted, but that’s still no client-server structure.
I’ve been reading the docs but honestly I have no clue.
I’m not sure if I have to code the server from scratch or if I can convert my current master client game to a dedicated server somehow?

Can’t I just make a unity build which is the master client that creates the room without spawning a player etc, and client builds that simply join a hard coded room name aka the master client’s room?

Hey.
I’m sorry to say but, no, you can’t just compile the client into a server with PUN. It needs a Photon Server and the server is usually not authoritative in the sense you mean it. It’s passing and caching events on behalf of the clients, so it’s also not just a dumb relay either.

But if you have a Master Client running and any client may take over that duty, why worry and change it into a dedicated host running in-Unity?

If you definitely want the structure you asked for, and if your project is new-ish, you could switch to Photon Bolt, which is more along the lines of what you look out for.

Well because that’s the task I got.
“Clients can’t host games, they simply connect to the persistent game that the server hosts” so basically an mmo-like server.

So what I did now is create a unity build that creates the game, is always the master client (so the server), but doesn’t spawn a player, and all players can just join and leave.

I can pass all the events through the master client, and the master client broadcasts to all the players, so it’s master client authorative, which is basically what I need.

This was the easiest and fastest way to make it work, but probably not correct.

So I’m still wondering how I would create a persistent game on a server?

Well, you can implement your case any way that works. From our point of view, this has however a few drawbacks. Namely: All messages have to go to the Photon Server and to the Master Client, then it has to act on the input and send messages the same way back. That means extra hops.

You can implement some logic in the server by using Photon Server Plugins. You would either have to check out how PUN’s messages look like or you would implement this using RaiseEvent in the client and the respective hook in the server plugin.
Photon Server runs on Windows but otherwise has no special requirements.

Persistence: With PUN, persistence is difficult, as each client is usually authoritative about the objects it created. But if a player leaves, the objects may stay in the room and the Master Client takes over authority. The server does never handle objects for inactive players. So it’s tricky to handle returning players and PUN doesn’t do this well. For persistence, it’s better not to use PhotonViews and to use RaiseEvent instead. Cached events in the server and the Room- and player-properties can be saved.

See:

1 Like