Nebula
Bootstrap

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.

generated from the sources
public static class 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. 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 Record

What 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 Verdict

What a client should do about the server.

Members

NameValueDescription
WaitingNo server of this session has started yet: keep waiting.
ReadyThe server is listening: connect to Record.port.
FailedThe server could not start: do not connect anywhere.

On this page