mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-02-13 13:44:57 +00:00
Convert main static references off of Electron into interface implementation and expose the underlying Socket for low level interaction.
This commit is contained in:
65
ElectronNET.API/Interfaces/IIpcMain.cs
Executable file
65
ElectronNET.API/Interfaces/IIpcMain.cs
Executable file
@@ -0,0 +1,65 @@
|
||||
using System;
|
||||
|
||||
namespace ElectronNET.API.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// Communicate asynchronously from the main process to renderer processes.
|
||||
/// </summary>
|
||||
public interface IIpcMain
|
||||
{
|
||||
/// <summary>
|
||||
/// Listens to channel, when a new message arrives listener would be called with
|
||||
/// listener(event, args...).
|
||||
/// </summary>
|
||||
/// <param name="channel">Channelname.</param>
|
||||
/// <param name="listener">Callback Method.</param>
|
||||
void On(string channel, Action<object> listener);
|
||||
|
||||
/// <summary>
|
||||
/// Send a message to the renderer process synchronously via channel,
|
||||
/// you can also send arbitrary arguments.
|
||||
///
|
||||
/// Note: Sending a synchronous message will block the whole renderer process,
|
||||
/// unless you know what you are doing you should never use it.
|
||||
/// </summary>
|
||||
/// <param name="channel"></param>
|
||||
/// <param name="listener"></param>
|
||||
void OnSync(string channel, Func<object, object> listener);
|
||||
|
||||
/// <summary>
|
||||
/// Adds a one time listener method for the event. This listener is invoked only
|
||||
/// the next time a message is sent to channel, after which it is removed.
|
||||
/// </summary>
|
||||
/// <param name="channel">Channelname.</param>
|
||||
/// <param name="listener">Callback Method.</param>
|
||||
void Once(string channel, Action<object> listener);
|
||||
|
||||
/// <summary>
|
||||
/// Removes listeners of the specified channel.
|
||||
/// </summary>
|
||||
/// <param name="channel">Channelname.</param>
|
||||
void RemoveAllListeners(string channel);
|
||||
|
||||
/// <summary>
|
||||
/// Send a message to the renderer process asynchronously via channel, you can also send
|
||||
/// arbitrary arguments. Arguments will be serialized in JSON internally and hence
|
||||
/// no functions or prototype chain will be included. The renderer process handles it by
|
||||
/// listening for channel with ipcRenderer module.
|
||||
/// </summary>
|
||||
/// <param name="browserWindow">BrowserWindow with channel.</param>
|
||||
/// <param name="channel">Channelname.</param>
|
||||
/// <param name="data">Arguments data.</param>
|
||||
void Send(BrowserWindow browserWindow, string channel, params object[] data);
|
||||
|
||||
/// <summary>
|
||||
/// Send a message to the BrowserView renderer process asynchronously via channel, you can also send
|
||||
/// arbitrary arguments. Arguments will be serialized in JSON internally and hence
|
||||
/// no functions or prototype chain will be included. The renderer process handles it by
|
||||
/// listening for channel with ipcRenderer module.
|
||||
/// </summary>
|
||||
/// <param name="browserView">BrowserView with channel.</param>
|
||||
/// <param name="channel">Channelname.</param>
|
||||
/// <param name="data">Arguments data.</param>
|
||||
void Send(BrowserView browserView, string channel, params object[] data);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user