mirror of
https://github.com/chylex/Minecraft-Phantom-Panel.git
synced 2024-11-23 19:42:51 +01:00
27 lines
846 B
C#
27 lines
846 B
C#
using NetMQ.Sockets;
|
|
using Phantom.Utils.Logging;
|
|
|
|
namespace Phantom.Utils.Rpc.Sockets;
|
|
|
|
sealed class RpcServerSocket : RpcSocket<ServerSocket> {
|
|
public static RpcServerSocket Connect(RpcConfiguration config) {
|
|
var socket = new ServerSocket();
|
|
var options = socket.Options;
|
|
|
|
options.CurveServer = true;
|
|
options.CurveCertificate = config.ServerCertificate;
|
|
RpcSocket.SetDefaultSocketOptions(options);
|
|
|
|
var url = config.TcpUrl;
|
|
var logger = PhantomLogger.Create(config.LoggerName);
|
|
|
|
logger.Information("Starting ZeroMQ server on {Url}...", url);
|
|
socket.Bind(url);
|
|
logger.Information("ZeroMQ server initialized, listening for connections on port {Port}.", config.Port);
|
|
|
|
return new RpcServerSocket(socket, config);
|
|
}
|
|
|
|
private RpcServerSocket(ServerSocket socket, RpcConfiguration config) : base(socket, config) {}
|
|
}
|