/// <summary> /// /// </summary> /// <param name="options"></param> public PacketProtocol(MessengerOptions options) { this.options = options; // We allocate the buffer for receiving message lengths immediately this.lengthBuffer = new byte[sizeof(int)]; this.maxMessageSize = options.MaxMessageSize;// maxMessageSize; }
/// <summary> /// /// </summary> /// <param name="options"></param> /// <param name="address"></param> /// <param name="port"></param> public SocketListener(MessengerOptions options, IPAddress address, int port) { this.options = options; //log = new Logger<SocketListener>(); listenTo = address ?? IPAddress.Any; this.port = port; //this.logMessages = logMessages; }
/// <summary> /// /// </summary> /// <param name="logger"></param> /// <param name="options"></param> /// <param name="loggerFactory"></param> public Messenger(ILogger <Messenger> logger, IOptions <MessengerOptions> options, ILoggerFactory loggerFactory) { this.log = logger; this.options = options.Value; this.loggerFactory = loggerFactory; this.router = new MessageRouter(loggerFactory.CreateLogger <MessageRouter>()); if (!this.options.DisableMulticastListening) { this.StartMulticastListener().ConfigureAwait(false); this.AddMulticastSubscription <MulticastTest>((m) => MulticastTestHandler(m as MulticastTest)); } }
internal MulticastSender(MessengerOptions options //string multicastAddress, int multicastPort, string localIpAddress , ILoggerFactory lf) { this.options = options; this.log = lf.CreateLogger <MulticastSender>(); sendClient = new UdpClient(); sendClient.EnableMulticast(options.MulticastIPAddress, options.MulticastPort, options.LocalCIDR); sendTo = new IPEndPoint(IPAddress.Parse(options.MulticastIPAddress), options.MulticastPort); InitialiseQueue(); log.Information($"sender enabled, {options.MulticastIPAddress}:{options.MulticastPort}"); }
internal MulticastListener(MessengerOptions options, ILoggerFactory lf) { try { this.options = options; this.log = lf.CreateLogger <MulticastListener>(); client = new UdpClient(); client.EnableMulticast(options.MulticastIPAddress, options.MulticastPort, options.LocalCIDR); } catch (Exception xe) { log.Error(xe); throw; } }