NETWORK API

The Microsoft Flight Simulator 2024 Networking API exposes a number of functions that permit you to make HTTP requests using WASM.

 

There are two principle ways to use this API:

  • Loop: This means that you will be in charge of checking the status of all your requests each frame using a loop. When using loops, keep in mind that once the request is done, data, errorCode, headers, etc... will only be available for one single frame. If you miss this frame, then there is nothing you can do. It is also worth noting that you cannot make this synchronous, as it won't work and it will lead to an infinite loop.
  • Callback: This means that Microsoft Flight Simulator 2024 will take the responsibility for checking the status and making the given callback once the request is done (whether it's a success or a fail).

It is important to note that there is a limited amount of WASM requests that can be processed at the same time (for now it is limited to 3). Also keep in mind that those handles are shared by every WASM module running at the same time, meaning that you have to think ahead and be careful to not make too many requests.

 

Finally, note that only https requests are permitted by the API.

 

You can find a sample project to use as a reference when using the Network API here:

 

 

Functions

The functions available with the Network API are:

Function Description
fsNetworkHttpCancelRequest Cancel a request made earlier whatever its state
fsNetworkHttpRequestGet Create a GET request which will be executed
fsNetworkHttpRequestGetData Get the data returned by the request
fsNetworkHttpRequestGetDataSize Get the data size returned by the request
fsNetworkHttpRequestGetErrorCode Get the request's error code
fsNetworkHttpRequestGetHeaderSection Get the value of a specific header
fsNetworkHttpRequestGetState Get the current status of a request
fsNetworkHttpRequestPOST Create a POST request which will be executed
fsNetworkHttpRequestPut Create a PUT request which will be executed

 

 

Enums/Structs

The enums and structs available for use with the Network API are:

Function Description Type
FsNetworkHttpRequestParam A structure which can/must be used while doing a request to customize the request. Struct
FsNetworkHttpRequestState The current state of a request. Enum

 

 

Typedefs

When using the functions listed below, you'll need to also have the following type definitions, as they will be used as return values or to create callbacks by many of the functions. These typedefs are:

 

 

FsNetworkRequestId

This is used as the return holding a request ID by many functions:

typedef long long FsNetworkRequestId;

 

 

HttpRequestCallback

This is used when a function requires a callback:

typedef void (*HttpRequestCallback)(FsNetworkRequestId requestId, int errorCode, void* userData);