> For the complete documentation index, see [llms.txt](https://kinematicsoup.gitbook.io/reactor/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kinematicsoup.gitbook.io/reactor/api-reference/ks.reactor.client.unity.editor/ks.reactor.client.unity.editor.kslocalserver.md).

# Class ksLocalServer

Namespace: [KS.Reactor.Client.Unity.Editor](/reactor/api-reference/ks.reactor.client.unity.editor.md)\
Assembly: KSUnity-Source.dll

Tracks a local Reactor or Cluster server instance and provides methods for starting and stopping it.

```csharp
[Serializable]
public class ksLocalServer
```

#### Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) â† [ksLocalServer](/reactor/api-reference/ks.reactor.client.unity.editor/ks.reactor.client.unity.editor.kslocalserver.md)

#### Inherited Members

[object.Equals(object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals\(system-object\)), [object.Equals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals\(system-object-system-object\)), [object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode), [object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype), [object.MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone), [object.ReferenceEquals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals), [object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)

## Constructors

### ksLocalServer(string) <a href="#ks_reactor_client_unity_editor_kslocalserver__ctor_system_string" id="ks_reactor_client_unity_editor_kslocalserver__ctor_system_string"></a>

Constructor

```csharp
public ksLocalServer(string id = "")
```

#### Parameters

`id` [string](https://learn.microsoft.com/dotnet/api/system.string)

Instance ID

## Fields

### CLUSTER <a href="#ks_reactor_client_unity_editor_kslocalserver_cluster" id="ks_reactor_client_unity_editor_kslocalserver_cluster"></a>

Cluster type constant

```csharp
public const byte CLUSTER = 1
```

#### Field Value

[byte](https://learn.microsoft.com/dotnet/api/system.byte)

### CLUSTER\_INSTANCE <a href="#ks_reactor_client_unity_editor_kslocalserver_cluster_instance" id="ks_reactor_client_unity_editor_kslocalserver_cluster_instance"></a>

Cluster instance type constant

```csharp
public const byte CLUSTER_INSTANCE = 2
```

#### Field Value

[byte](https://learn.microsoft.com/dotnet/api/system.byte)

### INSTANCE <a href="#ks_reactor_client_unity_editor_kslocalserver_instance" id="ks_reactor_client_unity_editor_kslocalserver_instance"></a>

Instance type constant

```csharp
public const byte INSTANCE = 0
```

#### Field Value

[byte](https://learn.microsoft.com/dotnet/api/system.byte)

## Properties

### Id <a href="#ks_reactor_client_unity_editor_kslocalserver_id" id="ks_reactor_client_unity_editor_kslocalserver_id"></a>

ID of the tracked instance.

```csharp
public string Id { get; }
```

#### Property Value

[string](https://learn.microsoft.com/dotnet/api/system.string)

### IsClusterInstance <a href="#ks_reactor_client_unity_editor_kslocalserver_isclusterinstance" id="ks_reactor_client_unity_editor_kslocalserver_isclusterinstance"></a>

Is this an instance started by a cluster?

```csharp
public bool IsClusterInstance { get; }
```

#### Property Value

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

### IsInstance <a href="#ks_reactor_client_unity_editor_kslocalserver_isinstance" id="ks_reactor_client_unity_editor_kslocalserver_isinstance"></a>

Is this an instance or cluster process (true if either)?

```csharp
public bool IsInstance { get; }
```

#### Property Value

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

### IsRunning <a href="#ks_reactor_client_unity_editor_kslocalserver_isrunning" id="ks_reactor_client_unity_editor_kslocalserver_isrunning"></a>

Is the local server instance running?

```csharp
public bool IsRunning { get; }
```

#### Property Value

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

### LogFile <a href="#ks_reactor_client_unity_editor_kslocalserver_logfile" id="ks_reactor_client_unity_editor_kslocalserver_logfile"></a>

Gets the path of the log file returning a string.

```csharp
public string LogFile { get; }
```

#### Property Value

[string](https://learn.microsoft.com/dotnet/api/system.string)

### Manager <a href="#ks_reactor_client_unity_editor_kslocalserver_manager" id="ks_reactor_client_unity_editor_kslocalserver_manager"></a>

Gets the local server manager singleton, returning a [ksLocalServerManager](/reactor/api-reference/ks.reactor.client.unity.editor/ks.reactor.client.unity.editor.kslocalservermanager.md) object.

```csharp
public static ksLocalServerManager Manager { get; }
```

#### Property Value

[ksLocalServerManager](/reactor/api-reference/ks.reactor.client.unity.editor/ks.reactor.client.unity.editor.kslocalservermanager.md)

### Port <a href="#ks_reactor_client_unity_editor_kslocalserver_port" id="ks_reactor_client_unity_editor_kslocalserver_port"></a>

Port used by the instance/cluster.

```csharp
public ushort Port { get; }
```

#### Property Value

[ushort](https://learn.microsoft.com/dotnet/api/system.uint16)

### ProcessId <a href="#ks_reactor_client_unity_editor_kslocalserver_processid" id="ks_reactor_client_unity_editor_kslocalserver_processid"></a>

Instance process ID.

```csharp
public int ProcessId { get; }
```

#### Property Value

[int](https://learn.microsoft.com/dotnet/api/system.int32)

### Protocol <a href="#ks_reactor_client_unity_editor_kslocalserver_protocol" id="ks_reactor_client_unity_editor_kslocalserver_protocol"></a>

Protocol used by the instance.

```csharp
public string Protocol { get; }
```

#### Property Value

[string](https://learn.microsoft.com/dotnet/api/system.string)

### Room <a href="#ks_reactor_client_unity_editor_kslocalserver_room" id="ks_reactor_client_unity_editor_kslocalserver_room"></a>

Room type of the instance.

```csharp
public string Room { get; }
```

#### Property Value

[string](https://learn.microsoft.com/dotnet/api/system.string)

### RoomPorts <a href="#ks_reactor_client_unity_editor_kslocalserver_roomports" id="ks_reactor_client_unity_editor_kslocalserver_roomports"></a>

Room ports assigned by the cluster to new room instances.

```csharp
public string RoomPorts { get; }
```

#### Property Value

[string](https://learn.microsoft.com/dotnet/api/system.string)

### Scene <a href="#ks_reactor_client_unity_editor_kslocalserver_scene" id="ks_reactor_client_unity_editor_kslocalserver_scene"></a>

Scene name of the instance.

```csharp
public string Scene { get; }
```

#### Property Value

[string](https://learn.microsoft.com/dotnet/api/system.string)

### Tags <a href="#ks_reactor_client_unity_editor_kslocalserver_tags" id="ks_reactor_client_unity_editor_kslocalserver_tags"></a>

Tags to apply to the cluster launch rooms returning a string.

```csharp
public string Tags { get; }
```

#### Property Value

[string](https://learn.microsoft.com/dotnet/api/system.string)

## Methods

### CheckConfigAndRuntime(string) <a href="#ks_reactor_client_unity_editor_kslocalserver_checkconfigandruntime_system_string" id="ks_reactor_client_unity_editor_kslocalserver_checkconfigandruntime_system_string"></a>

Checks if the config files and server runtime dll needed to run a local server are present. If not, prompts the user to build them.

```csharp
public bool CheckConfigAndRuntime(string scene)
```

#### Parameters

`scene` [string](https://learn.microsoft.com/dotnet/api/system.string)

Name of the scene to find config for.

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

True if the files were found or built.

### CheckServerProjectDirtyFlag() <a href="#ks_reactor_client_unity_editor_kslocalserver_checkserverprojectdirtyflag" id="ks_reactor_client_unity_editor_kslocalserver_checkserverprojectdirtyflag"></a>

Checks if the server project is dirty. If so, ask the user if they want to build the server runtime before starting the local server.

```csharp
public void CheckServerProjectDirtyFlag()
```

### DeleteLockFile() <a href="#ks_reactor_client_unity_editor_kslocalserver_deletelockfile" id="ks_reactor_client_unity_editor_kslocalserver_deletelockfile"></a>

Delete the local server lock file.

```csharp
public void DeleteLockFile()
```

### FindProcess() <a href="#ks_reactor_client_unity_editor_kslocalserver_findprocess" id="ks_reactor_client_unity_editor_kslocalserver_findprocess"></a>

Finds the local server process started by this local server instance. The process reference is lost during Unity serialization, so we serialize the process ID and call this to retrieve the process after serialization.

```csharp
public bool FindProcess()
```

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

### Get(string) <a href="#ks_reactor_client_unity_editor_kslocalserver_get_system_string" id="ks_reactor_client_unity_editor_kslocalserver_get_system_string"></a>

Get a local server instance for a room type. If a local server instance of the room type is running, that instance will be returned. If not, a new instance is created (but not started). ksLocalServer is not aware of local server processes started externally and will not return a local server instance for those processes.

```csharp
public static ksLocalServer Get(string id = "")
```

#### Parameters

`id` [string](https://learn.microsoft.com/dotnet/api/system.string)

Unique instance ID.

#### Returns

[ksLocalServer](/reactor/api-reference/ks.reactor.client.unity.editor/ks.reactor.client.unity.editor.kslocalserver.md)

Object matching the room type.

### Init() <a href="#ks_reactor_client_unity_editor_kslocalserver_init" id="ks_reactor_client_unity_editor_kslocalserver_init"></a>

Initialization method to create non-serialized member variables because unity assigns them a null value after deserialisation.

```csharp
public void Init()
```

### Load(ksLocalServerData) <a href="#ks_reactor_client_unity_editor_kslocalserver_load_ks_reactor_client_unity_editor_kslocalserverdata" id="ks_reactor_client_unity_editor_kslocalserver_load_ks_reactor_client_unity_editor_kslocalserverdata"></a>

Loads running local server instances through the manager, a [ksLocalServerManager](/reactor/api-reference/ks.reactor.client.unity.editor/ks.reactor.client.unity.editor.kslocalservermanager.md) object.

```csharp
public static void Load(ksLocalServerData data)
```

#### Parameters

`data` [ksLocalServerData](/reactor/api-reference/ks.reactor.client.unity.editor/ks.reactor.client.unity.editor.kslocalserverdata.md)

Local server instances.

### LoadLockFile(string) <a href="#ks_reactor_client_unity_editor_kslocalserver_loadlockfile_system_string" id="ks_reactor_client_unity_editor_kslocalserver_loadlockfile_system_string"></a>

Loads local server data from a lock file.

```csharp
public void LoadLockFile(string path)
```

#### Parameters

`path` [string](https://learn.microsoft.com/dotnet/api/system.string)

Path to the lock file to load from.

### Restart() <a href="#ks_reactor_client_unity_editor_kslocalserver_restart" id="ks_reactor_client_unity_editor_kslocalserver_restart"></a>

Restart the local server process.

```csharp
public void Restart()
```

### StartCluster(string, string, ushort, string, string, string) <a href="#ks_reactor_client_unity_editor_kslocalserver_startcluster_system_string_system_string_system_uint16" id="ks_reactor_client_unity_editor_kslocalserver_startcluster_system_string_system_string_system_uint16"></a>

Start a Cluster instance.

```csharp
public void StartCluster(string scene, string room, ushort port, string roomPorts, string tags, string protocol = "tcp")
```

#### Parameters

`scene` [string](https://learn.microsoft.com/dotnet/api/system.string)

Scene name.

`room` [string](https://learn.microsoft.com/dotnet/api/system.string)

Room name.

`port` [ushort](https://learn.microsoft.com/dotnet/api/system.uint16)

Instance port.

`roomPorts` [string](https://learn.microsoft.com/dotnet/api/system.string)

Cluster room ports.

`tags` [string](https://learn.microsoft.com/dotnet/api/system.string)

Cluster tags.

`protocol` [string](https://learn.microsoft.com/dotnet/api/system.string)

Protocol used by cluster rooms.

### StartInstance(string, string, ushort, string) <a href="#ks_reactor_client_unity_editor_kslocalserver_startinstance_system_string_system_string_system_uint16" id="ks_reactor_client_unity_editor_kslocalserver_startinstance_system_string_system_string_system_uint16"></a>

Start a Reactor instance.

```csharp
public void StartInstance(string scene, string room, ushort port, string protocol = "tcp")
```

#### Parameters

`scene` [string](https://learn.microsoft.com/dotnet/api/system.string)

Scene name.

`room` [string](https://learn.microsoft.com/dotnet/api/system.string)

Room name.

`port` [ushort](https://learn.microsoft.com/dotnet/api/system.uint16)

Instance port.

`protocol` [string](https://learn.microsoft.com/dotnet/api/system.string)

### Stop(bool) <a href="#ks_reactor_client_unity_editor_kslocalserver_stop_system_boolean" id="ks_reactor_client_unity_editor_kslocalserver_stop_system_boolean"></a>

Stops this local server instance.

```csharp
public void Stop(bool removeFromManager = true)
```

#### Parameters

`removeFromManager` [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

Whether the instance should be removed from the [Manager](#KS_Reactor_Client_Unity_Editor_ksLocalServer_Manager).
