4 using System.Collections.Generic;
15 [Script(ScriptRole.Server)]
18 public Timeline<string> SpawnRequests;
19 public Timeline<GameMessage> ServerSpawns;
21 const float TIMEOUT_DURATION = 5.0f;
26 SpawnRequests =
Sync.CreateEvent<
string>();
32 SpawnRequests.EntryPassed += OnSpawnRequestReceived;
46 void OnSpawnRequestReceived (Timeline<string> timeline, TimelineEntry<string> entry)
51 StartCoroutine(TimeoutAsync());
55 void OnServerSpawned (GameServerType serverType,
string mapId, IPEndPoint endPoint)
58 msg.Write((byte)serverType);
62 ServerSpawns[0] = msg;
65 IEnumerator TimeoutAsync ()
67 _requestTimeout =
true;
68 yield
return new WaitForSeconds(TIMEOUT_DURATION);
69 _requestTimeout =
false;
72 void OnServerSpawnFailed (GameServerType serverType,
string mapId)
75 Debug.Log(
string.Format(
"Server spawn failed. ID: {1} Type: {0}.", serverType, mapId));
static GameServer Instance
Gets the sole instance of this game server.
ServerSpawnedHandler ServerSpawned
Event fired when a requested server spawn is successful.
void RequestServerSpawn(GameServerType serverType, string mapId)
Sends a server spawn request to the world server.
ServerSpawnFailedHandler ServerSpawnFailed
Event fired when a requested server spawn fails.
A Component used to decouple the Server side logic of a minigame portal from the MinigamePortal class...
A class for serializing game data into a stream for propagation between objects and peers...
This class server two main functions: 1) As a MonoBehaviour, it allows for network synchronization of...