FxEvents.Server 2.9.1

dotnet add package FxEvents.Server --version 2.9.1
NuGet\Install-Package FxEvents.Server -Version 2.9.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FxEvents.Server" Version="2.9.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add FxEvents.Server --version 2.9.1
#r "nuget: FxEvents.Server, 2.9.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install FxEvents.Server as a Cake Addin
#addin nuget:?package=FxEvents.Server&version=2.9.1

// Install FxEvents.Server as a Cake Tool
#tool nuget:?package=FxEvents.Server&version=2.9.1

FxEvents an advanced event subsystem for FiveM

With FxEvents you can send and get values between client and server using an advanced event handling process. Signatures are encrypted per each client and using the provided MsgPack binary serialization you can hide contents from malicious clients! To work you only need to add FXEvents.Client.dll or FXEvents.Server.dll and Newtonsoft.Json.dll (In case of json serialization) to your resource. No need of any external library for MsgPack, the event system uses the internal MsgPack dll provided with fivem itself!!

Discord Server Invite

Usage examples:

Initialization

  • Encryption key CANNOT remain empty or null, you can generate encryption keys, passphrases, passwords online or use the provided serverside command generagekey to let the library generate a random passphrase both literal and encrtypted to be copied and stored in a safe place. PLEASE NOTE: FXEvents won't store nor save any passkey anywhere for security reasons, do not lose the key or your data won't be recovered.
public class Main : BaseScript
{
 public Main()
 {
  // The Event Dispatcher can now be initialized with your own inbound, outbound, and signatures.
  // This allows you to use FxEvents in more than one resource on the server without having signature collisions.
  EventDispatcher.Initalize("inbound", "outbound", "signature", "encryption key");
 }
}

To mount an event:

  • Events can be mounted like normal events, this example is made to show an event mounted in-line.
EventDispatcher.Mount("eventName", new Action<ISource, type1, type2>(([FromSource] source, val1, val2) =>    
{
  // code to be used inside the event.
  // ISource is the optional insider class that handles clients triggering the event.. is like the "[FromSource] Player player" parameter but can be derived and handled as you want!!
  // Clientside is the same thing without the ClientId parameter
}));

To trigger an event

The library only works in client ←-> server communication.. for the moment same side events are not working but the feature will be added in the future!

// clientside
EventDispatcher.Send("eventName", params);

// serverside
EventDispatcher.Send(Player, "eventName", params);
EventDispatcher.Send(List<Player>, "eventName", params);
EventDispatcher.Send(ISource, "eventName", params);
EventDispatcher.Send(List<ISource>, "eventName", params);
EventDispatcher.Send("eventName", params); // For all Connected Players

To trigger a callback

Mounting it

EventDispatcher.Mount("eventName", new Func<ISource, type1, type2, Task<returnType>>(async ([FromSource] source, val1, val2) =>    
{
  // code to be used inside the event.
  // ISource is the optional insider class that handles clients triggering the event.. is like the "[FromSource] Player player" parameter but can be derived and handled as you want!!
  // Clientside is the same thing without the ISource parameter
  return val3
}));

Calling it

// clientside
type param = await EventDispatcher.Get<type>("eventName", params);

// serverside
type param = await EventDispatcher.Get<type>(ClientId, "eventName", params);
type param = await EventDispatcher.Get<type>(Player, "eventName", params);

Callbacks can be called serverside too because it might happen that the server needs info from certain clients and this will help you doing it.

The library comes with some goodies to help with customization and debugging serialization printing.

ToJson()

image

⚠️ You need Newtonsoft.Json to make this work!!

string text = param.ToJson();

FromJson()

⚠️ You need Newtonsoft.Json to make this work!!

type value = jsonText.FromJson<type>();

ToBytes()

image

byte[] bytes = param.ToBytes();

FromBytes()

type value = bytes.FromBytes<type>();

EncryptObject(string passkey)

  • Binary serialization performed internally.
byte[] bytes = param.EncryptObject("passkey");

DecryptObject(string passkey)

  • Binary deserialization performed internally.
T object = bytes.DecryptObject<T>("passkey");

BytesToString

byte[] bytes = param.ToBytes();
string txt = bytes.BytesToString();

StringToBytes

byte[] bytes = txt.StringToBytes();
type value = bytes.FromBytes<type>();
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.9.1 96 4/8/2024
2.9.0 92 4/5/2024
2.8.4 82 4/4/2024
2.6.0 188 12/21/2023
2.5.4 160 11/8/2023
2.5.3 113 11/8/2023
2.5.2 89 11/8/2023
2.5.1 91 11/8/2023
2.5.1-beta0 64 11/8/2023
2.5.0 126 9/29/2023
2.0.0-beta3-monov2 97 6/18/2023
2.0.0-beta2-monov2 102 5/29/2023
2.0.0-beta1-monov2 120 5/19/2023
1.0.4 114 9/5/2023
1.0.3 158 4/24/2023