using IpcLibrary.Core;
using IpcLibrary.Core.Exceptions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace IpcLibrary.Client {
///
/// IPC客户端工厂
///
public static class IPCClientFactory {
///
/// 创建默认配置的客户端
///
public static IIPCClient CreateClient() {
return new IPCClient();
}
///
/// 创建自定义配置的客户端
///
public static IIPCClient CreateClient(IPCConfiguration configuration) {
return new IPCClient(configuration);
}
///
/// 创建并连接客户端
///
public static async Task CreateAndConnectAsync(string serverAddress, IPCConfiguration configuration = null) {
var client = new IPCClient(configuration);
if (!await client.ConnectAsync(serverAddress)) {
client.Dispose();
throw new ConnectionException("无法连接到服务器");
}
return client;
}
}
}