Show / Hide Table of Contents

Class TrimmerServer

Server is a simple TCP server that allows to access Trimmer configuration over the network.

Inheritance
System.Object
TrimmerServer
Namespace: sttz.Trimmer.Options
Assembly: Trimmer.dll
Syntax
public class TrimmerServer
Remarks

The server essentially provides a network API to the RuntimeProfile. You can use TrimmerClient to connect to the server. The server currently only allows a single client to be connected at a time.

The protocol is very simple and can also be used with a command line tool like nc or socat.

You can use socat to discover servers on the local network (replace TRIM with ClientHello and 21076 with ServerPort):

echo "TRIM" | socat -d -d - UDP-DATAGRAM:255.255.255.255:21076,broadcast

Connect to a server (replacing 127.0.0.1 with the server IP and again 21076 with the server port):

socat readline TCP:127.0.0.1:21076

Then you can type commands to send to the server. First send the client hello and then use the available commands:

  • GET OPTION_PATH: Get the value of an Option using its path in ini-format.
  • SET OPTION_PATH = VALUE: Set the value of an Option using its path.
  • PING: Simple ping, server responds with PONG.

The server allows you to add custom commands using AddCommand(String, TrimmerServer.CommandHandler).

If you use this class directly, make sure you call Update() regularly for the server to process commands.

Warning

The communication is unencrypted and doesn't use authentication. The use of this server is only intended for development.

Constructors

| Improve this Doc View Source

TrimmerServer()

Declaration
public TrimmerServer()

Properties

| Improve this Doc View Source

ClientHello

Expected string to receive from clients for discovery and connections.

Declaration
public string ClientHello { get; set; }
Property Value
Type Description
System.String
| Improve this Doc View Source

IsDiscoverable

Sets wether the server replies to broadcast inquiries, which lets clients detect available servers.

Declaration
public bool IsDiscoverable { get; set; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

IsRunning

Wether the server is currently running.

Declaration
public bool IsRunning { get; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

ServerHelloFormat

Hello sent back to the client.

Declaration
public string ServerHelloFormat { get; set; }
Property Value
Type Description
System.String
Remarks

The format string can contain following placeholders:

  • {0}: Application.productName
  • {1}: Application.version
  • {2}: Application.unityVersion
| Improve this Doc View Source

ServerPort

The port the server is listening on.

Declaration
public int ServerPort { get; set; }
Property Value
Type Description
System.Int32

Methods

| Improve this Doc View Source

AddCommand(String, TrimmerServer.CommandHandler)

Add a custom command to the server.

Declaration
public void AddCommand(string name, TrimmerServer.CommandHandler handler)
Parameters
Type Name Description
System.String name

The name of the command

TrimmerServer.CommandHandler handler

Handler to respond to an incoming command

Remarks

As a convention, commands return ERROR Message here in case an error is encountered.

| Improve this Doc View Source

Start()

Start the server.

Declaration
public void Start()
Remarks

Does nothing is the server is already running.

| Improve this Doc View Source

Stop()

Stop the server.

Declaration
public void Stop()
Remarks

Does nothing is the server is not running.

| Improve this Doc View Source

Update()

Call this method in a regular interval to process client messages.

Declaration
public void Update()
  • Improve this Doc
  • View Source
Back to top © 2017 Adrian Stutz