EditorDevSession
Binds the clients of the Multiplayer Play Mode dev loop to the server their own session started, so a client never joins some other mesh that happens to hold the port.
Nebula · Packages/com.1by3.nebula/Runtime/Bootstrap/EditorDevSession.cspublic static class EditorDevSessionBinds the clients of the Multiplayer Play Mode dev loop to the server their own session started, so a client never joins some other mesh that happens to hold the port. The server writes Library/Nebula/dev-session.json once its gateway and worker have bound their ports, or failed to, and deletes it when it stops. A client waits for the file, connects to the port it names while the process that wrote it is alive, and refuses with the server's reason when the server could not start.
Fields
ListeningState
public const string ListeningState = "listening";FailedState
public const string FailedState = "failed";Properties
CurrentPid
public static int CurrentPid { get; }This process's id.
Methods
PathFor
public static string PathFor(string projectRoot);The file: <project>/Library/Nebula/dev-session.json.
Evaluate
public static Verdict Evaluate(Record record, Func<int, bool> isAlive);Judge a record. A missing record, one whose writer is no longer running (a server that crashed without removing it), or one in an unknown state means the session's server has not started yet.
FailureMessage
public static string FailureMessage(Record record);The error a client logs when the server of its session could not start.
Write
public static void Write(string path, Record record);Write the server's record; replaces the previous one.
Read
public static Record Read(string path);Read the record, or null when there is none or it is being written.
Remove
public static void Remove(string path, int pid);Remove the record when it is this process's, as a server stops.
IsAlive
public static bool IsAlive(int pid);Whether a process with this id is running.
Nested types
Record
[Serializable]
public sealed class RecordWhat the server wrote.
Fields
state
public string state = "";listening or failed.
port
public int port;The gateway port the server listens on, or failed to bind.
pid
public int pid;The server's process id: a file whose writer is gone is stale.
incarnation
public string incarnation = "";The gateway's incarnation, so the log can tell one server start from the next.
error
public string error = "";Why the server could not start, when state is failed.
Verdict
public enum VerdictWhat a client should do about the server.
Members
| Name | Value | Description |
|---|---|---|
Waiting | No server of this session has started yet: keep waiting. | |
Ready | The server is listening: connect to Record.port. | |
Failed | The server could not start: do not connect anywhere. |
EditorDevPaths
Where the Multiplayer Play Mode dev loop keeps its files: under the project's Library/Nebula, shared by the main Editor and every virtual player, and never read by a build.
EditorPlayer
What one Editor process does under NebulaEditorRunMode.MultiplayerPlayMode, decided by EditorRunPlan.Resolve from facts the bootstrap reads (whether this is the Editor, whether this is the main Editor or a virtual player, its Multiplayer...