Interface ISksePluginMessenger
- Namespace
- SkyrimForge
- Assembly
- SkyrimForge.dll
Sends messages to the other SKSE plugins in the load order and receives what they send.
This is one of the two ways a plugin reaches another. The commoner is an exported function the publisher names and the consumer finds through its module,
which needs nothing from the framework: NativeLibrary.TryGetExport reaches it and a function pointer calls it. This is the other way,
and it is the only one by which another plugin reaches a plugin here unprompted.
public interface ISksePluginMessenger
Remarks
A payload is an address in another plugin's memory, and nothing here says what resides there or how long it lasts. The sender and the receiver agree that between themselves, as they agree what the message type means.
Methods
Send(uint, nint, int, string?)
Sends a message to one plugin, or to every plugin listening where no receiver is named.
bool Send(uint messageType, nint data = 0, int length = 0, string? receiver = null)
Parameters
messageTypeuintHow the receiver is to read this message.
datanintThe payload's address, which must outlive the call. Sending is synchronous and every listener runs before this returns.
lengthintHow many bytes the payload occupies.
receiverstringThe plugin to send to, named as Subscribe(string, Action<SksePluginMessage>) describes, or
nullto reach every plugin listening for this one.
Returns
- bool
Whether SKSE accepted the message. It declines one sent before plugins may message each other.
Exceptions
- ArgumentOutOfRangeException
lengthis negative.
Subscribe(string, Action<SksePluginMessage>)
Receives what one named plugin sends. The handler runs on the thread that sends the message.
ISubscription Subscribe(string sender, Action<SksePluginMessage> handler)
Parameters
senderstringThe plugin to listen for, named as it declares itself to SKSE rather than by its file. A plugin states that name in its version data, and the two differ: this framework ships as SkyrimForge.Runtime.dll and declares the name SkyrimForge, and a message from it states the second. PrismaUI.dll declares PrismaUI. The name a plugin logs itself under is the same one. Nothing here validates it, and a plugin that never loads sends nothing, so a misspelling and an absent plugin read alike: the handler never runs.
handlerAction<SksePluginMessage>A handler that throws is dropped, and its exception is written to the log of the plugin that subscribed it.
Returns
- ISubscription
A handle that stops the handler running. SKSE offers no way to withdraw a registration, so unsubscribing stops the handler being called rather than stopping the message arriving.
Exceptions
- ArgumentNullException
senderorhandlerisnull.- InvalidOperationException
SKSE declined the registration.