using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IpcLibrary.Core {
    /// <summary>
    /// IPC服务器接口
    /// </summary>
    public interface IIPCServer : IDisposable {
        bool IsRunning { get; }
        IReadOnlyList<ProcessInfo> ConnectedProcesses { get; }

        event EventHandler<ProcessInfo> ProcessConnected;
        event EventHandler<ProcessInfo> ProcessDisconnected;
        event EventHandler<IPCMessage> MessageReceived;

        Task StartAsync(string address);
        Task StopAsync();
        Task<T> CallMethodAsync<T>(string targetProcessId, string serviceName, string methodName, params object[] parameters);
        Task SendNotificationAsync(string targetProcessId, string method, params object[] parameters);
        Task BroadcastNotificationAsync(string method, params object[] parameters);
        Task RegisterServiceAsync<T>(string serviceName, T serviceInstance);
        Task UnregisterServiceAsync(string serviceName);
    }
}
