FN

FN contains all global properties related to FigNet Core

Properties

Is library initialized or not

public static bool IsInitialized { get; set; }

Read only Configuration instance, it gets populated based on ServerConfig.xml

public static Configuration Settings { get; }

Read only HandlerCollection instance, it is used to Register & UnRegister Handlers

public static HandlerCollection HandlerCollection { get; }

Read only PeerCollection instance, it is used to get connected peers based on type or Id

public static PeerCollection PeerCollection { get; }

Logger instance, we can set it to custom instance, it is used to log debug message to console or file

public static ILogger Logger { get; set; }

Read only List of Open ClientSocket Connection, it used to send and receive Messages to Server

public static List<IClientSocket> Connections { get; }

Read only ServerSocket instance, it used to send and receive Messages to connected clients

public static IServerSocket Server { get; }

Read only Dictionary of SerializeFunctions, it is used to serialize out going data (payloads of Messages)

public static Dictionary<ushort, SerializeFunction> SerializeFuncs { get; }

Read only Dictionary of DeserializeFunctions, it is used to Deserialize in coming data (payloads of Messages)

public static Dictionary<ushort, DeserializeFunction> DeserializeFuncs { get; }

Events

It is triggered on Settings (ServerConfig.xml) loaded

public static Action OnSettingsLoaded;

It is triggered after creation of IServerSocket & IClientSockets

public static Action OnInitilized;

Methods

Load Configuration based on ServerConfig.xml

public static void LoadConfig();

Create Instances of IServerSocket, IClientSockets and Modules based on Configuration

public static void Initilize();
public static void Initilize(Configuration config);

Stop IServerSocket Instance & IClientSockets and dispose them

public static void Deinitialize();

Load Modules as Plugin defined in ServerConfig.xml

public static void LoadModules(IServer server);

Create ClientSocket Instance and Add it to FN.Connections list based on Peers in ServerConfig.xml Params int config : points to peers index in settings IClientSocketListner socketListner : pass an instance to receiver socket events

public static void AddConnectionAndConnect(int config = 0, IClientSocketListener socketListener = null);

Create ClientSocket Instance and Add it to FN.Connections list based on Peers in ServerConfig.xml Params PeerConfig peerConfig : PeerConfig that is used to create socket instance IClientSocketListner socketListner : pass an instance to receiver socket events

public static void AddConnectionAndConnect(PeerConfig peerConfig, IClientSocketListener socketListener = null);

When AutoConnect is true in ServerConfig.xml, then this method can be used to bind listners to ClientSockets of FN.Connections. Note: call this method before OnInitialize event, OnSettingsLoaded event is a good place to register this event

public static void BindClientListner(params IClientSocketListener[] listener);

This method can be used to bind listner to ServerSockets of FN.Server Note: call this method before OnInitialize event, OnSettingsLoaded event is a good place to register this event

public static void BindServerListner(IServerSocketListener listener);

This method can be used to Remove a client connection from FN.Connections list and disconnect it by name

public static void RemoveConnectionAndDisconnect(string name);

This method can be used to Remove a client connection from FN.Connections list and disconnect it by index of FN.Connections

public static void RemoveConnectionAndDisconnect(int config = 0);

This method is used to Register payload serialize and deserialize functions against messageId

public static void RegisterPayload(ushort msgId, SerializeFunction serializeFunc, DeserializeFunction deserializeFunc);

By default if Logging level is set to ALL in ServerConfig.xml, the logger will log detailed log of every comming messages. This method can be used to view detailed log of subscribed messages only.

public static void SubscribeToDetailedLog(ushort messageId);

This method is used to unsubscribe the detailed log of perticular message. Note: if there is no message is subscribed the logger will print all in comming message

public static void UnSubscribeToDetailedLog(ushort messageId);

Last updated

Was this helpful?