# Configuration

### Common Attributes&#x20;

```xml
<?xml version="1.0" encoding="utf-16"?>
<Configuration xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <!--Avaliable Providers TCP, ENet, LiteNetLib, WebSockets-->
    <ApplicationType>Server</ApplicationType>
    <FrameRate>60</FrameRate>
    <EnableFileLogs>false</EnableFileLogs>
    <LoggingLevel>INFO</LoggingLevel><!--NONE, INFO, DEBUG, ALL-->
    <AppSecretKey>123</AppSecretKey>
    <EncryptionKey>MbQeThWmZq4t6w</EncryptionKey>
<!--Here add Modules-->
<!--Here add Server Socket Listner-->
<!--Here add Client Socket Listners-->
<!--Here add SubscribeDebugMessages-->
</Configuration>
```

**ApplicationType**: Server|Client, Weather you are running your app as server or client.

**FrameRate**: Tick rate of Network service function

**EnableFileLogs**: true|false, if set to false logs will be printed on console and if set to true logs will be printed in log file placed under logs/fileName.log it is placed next to executable.

**LoggingLevel**: NONE|INFO|DEBUG|ALL (should be in caps)

* NONE: no logs will be printed
* INFO: only basic messages will be printed e.g. Connection Started, Peer Connected & Disconnected etc.
* DEBUG: it prints info of all incoming & outgoing message of Sockets
* ALL: same as DEBUG + it prints content of incoming & outgoing traffic

\*for more details see Logging

{% content-ref url="logging" %}
[logging](https://m-ahmed310.gitbook.io/fignet/core-concepts/logging)
{% endcontent-ref %}

**AppSecretKey**: A secret key that is used to authenticate users, if a connecting client is not providing correct key it will be disconnected by sever.

**EncryptionKey**: FigNet has optional encryption that can be enabled per message and key used to encrypt the message \[needs to be same on both ends, server & client side]

### Modules Node

```xml
<Modules>
    <Module>
	<AssemblyName>Template</AssemblyName>
	    <Type>Template.Modules.Jokester.JokesterModule</Type>
	    <Dependencies>
		<Package>
		    <AssemblyName>LiteNetLib</AssemblyName>
		</Package>
	    </Dependencies>
    </Module>
</Modules>
```

**AssemblyName**: Name of DLL/Solution

**Type**: Name of class including namespace

**Package**: additional dependency your module depends on

For more details read Modules session

{% content-ref url="modules" %}
[modules](https://m-ahmed310.gitbook.io/fignet/core-concepts/modules)
{% endcontent-ref %}

### Server Config Node

```xml
<ServerConfigs>
    <ServerConfig>
	<Name>DemoServer</Name>
	<AppName>fignet</AppName>
	<Port>6000</Port>
	<Provider>TCP</Provider>
	<MaxChannels>1</MaxChannels>
	<MaxConnections>500</MaxConnections>
	<DisconnectTimeout>3000</DisconnectTimeout>
	<EnableCheckSum>false</EnableCheckSum>
	<MaxSendQueueSize>10000</MaxSendQueueSize>
	<MaxReceiveQueueSize>10000</MaxReceiveQueueSize>
	<IsMultiThreaded>true</IsMultiThreaded>
	<EnableDebugMessages>false</EnableDebugMessages>
    </ServerConfig>
    <!--here add more listener-->
</ServerConfigs>
```

**Name**: A descriptive name that can be used to query config instance

**Port**: Port number at which the server will listen for connections

**Provider**: Underneath Transport layer, available transports are \[ LiteNetLib, ENet, TCP, WS ]

**MaxChannels**: Max Channels, applicable to LiteNetLib & ENet

**MaxConnections**: Max Allowed connections, applicable to LiteNetLib & ENet

**DisconnectTimeout**: in milli seconds, If Server doesn't hear from clients after this time a timeout disconnect will be fired \[ applicable to LiteNetLib & ENet ]&#x20;

**EnableCheckSum**: It adds additional 4 bytes to every network message & provides protection to data corruptions, **\****this property needs to be same on both sides client & server*.&#x20;

**MaxSendQueueSize**: Every out-going message gets queued into this Queue till Networking process function serialize it dispatches it. If this queue gets filled oldest messages in the queue will be dropped.

**MaxReceiveQueueSize**: Every in-coming message gets queued into this queue till networking process function De-serialize it and trigger the network message received event. If this queue gets filled oldest messages in the queue will be dropped.

**IsMultiThreaded**: If set to true, Networking will be done on separate thread \[but on Network Receive events will be received on main thread because unity doesn't allows to call unity's object access from different threads ]

**EnableDebugMessages**: It enabled the internal logs of transport library, useful for debugging. Applicable to TCP & WebSockets only.

### Peers\[client] Config Node

```xml
  <PeerConfigs>
    <PeerConfig>
      <Name>test</Name>
      <Port>5555</Port>
      <PeerIp>localhost</PeerIp>
      <Provider>LiteNetLib</Provider>
      <AutoConnect>true</AutoConnect>
      <MaxChannels>1</MaxChannels>
      <DisconnectTimeout>3000</DisconnectTimeout>
      <EnableCheckSum>false</EnableCheckSum>
      <MaxSendQueueSize>10000</MaxSendQueueSize>
      <MaxReceiveQueueSize>10000</MaxReceiveQueueSize>
      <IsMultiThreaded>true</IsMultiThreaded>
    </PeerConfig>
    <!--here add more peers-->
  </PeerConfigs>
```

**Name**: A Descriptive name to access the config instance.

**Port**: Port number to connect to.

**PeerIp**: Ip of the Server.

**Provider**: Underneath Transport layer, available transports are \[ LiteNetLib, ENet, TCP, WS ], Server and Client have to have same provider to establish connect.&#x20;

**AutoConnect**: On App launch client automatically initiated the connection request

**MaxChannels**: Max Channels, applicable to LiteNetLib & ENet

**DisconnectTimeout**: in milli seconds, If Client doesn't hear from server, after this time a timeout disconnect will be fired \[ applicable to LiteNetLib & ENet ]&#x20;

**EnableCheckSum**: It adds additional 4 bytes to every network message & provides protection to data corruptions, this property needs to be same on both sides client & server.&#x20;

**MaxSendQueueSize**: Every out-going message gets queued into this Queue till Networking process function serialize it dispatches it. If this queue gets filled oldest messages in the queue will be dropped

**MaxReceiveQueueSize**: Every in-coming message gets queued into this queue till networking process function De-serialize it and trigger the network message received event. If this queue gets filled oldest messages in the queue will be dropped

**IsMultiThreaded**: If set to true, Networking will be done on separate thread \[but on Network Receive events will be received on main thread because unity doesn't allows to call unity's object access from different threads ]

### Peers\[client] Config Unity Editor Window

FigNet/Settings

![ServerConfig Unity Editor Window](https://2818635545-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mi5m6nRO5vqi3KSpWcd%2Fuploads%2Fg16TZxN60pr56Yp5PLdG%2Funity-setting.png?alt=media\&token=33de97a8-cab2-4086-92a8-fded6192cf77)

### SubscribeDebugMessages Node

```xml
<SubscribeDebugMessages>
    <MessageInfo>
	<Id>10</Id>
    </MessageInfo>
    <MessageInfo>
	<Id>5</Id>
    </MessageInfo>
    <!--here add more messageInfos-->
</SubscribeDebugMessages>
```

**Id**: Id of message that you wants to inspect

\*Note: this node is optional. When **LoggingLevel** in common settings is set to **ALL** it logs detailed info of every incoming & outgoing message. That can become overwhelming if server is receiving lots of message. Adding MessageInfo in SubscribeDebugMessages Node will log detailed info of subscribed message.&#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://m-ahmed310.gitbook.io/fignet/core-concepts/configuration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
