/// <summary> /// Initializes a new instance of the <see cref="T:LeanIPC.RPCPeer"/> class. /// </summary> /// <param name="connection">The connection to use for invoking methods.</param> /// <param name="allowedTypes">The types on which remote execution is allowed</param> /// <param name="filterPredicate">A predicate function used to filter which methods can be invoked</param> public RPCPeer(InterProcessConnection connection, Type[] allowedTypes, Func <System.Reflection.MemberInfo, object[], bool> filterPredicate) { m_connection = connection ?? throw new ArgumentNullException(nameof(connection)); m_connection.AddMessageHandler(HandleMessage); if (allowedTypes != null) { if (allowedTypes.Length != 0 && filterPredicate == null) { filterPredicate = (a, b) => true; } foreach (var at in allowedTypes) { m_allowedTypes.Add(at, filterPredicate); } } m_typeSerializer = m_connection.TypeSerializer ?? throw new ArgumentNullException(nameof(m_connection.TypeSerializer)); m_remoteObjects = m_connection.RemoteHandler ?? throw new ArgumentNullException(nameof(m_connection.RemoteHandler)); }
/// <summary> /// Initializes a new instance of the <see cref="T:LeanIPC.IPCPeer"/> class. /// </summary> /// <param name="reader">The stream to read from.</param> /// <param name="reader">The stream to write to.</param> /// <param name="authenticationHandler">The authentication code to use</param> /// <param name="serializer">The serializer to use</param> /// <param name="remoteHandler">The remote object handler to use</param> public IPCPeer(Stream reader, Stream writer, RemoteObjectHandler remoteHandler, TypeSerializer serializer, IAuthenticationHandler authenticationHandler = null) : this(new BinaryConverterStream(reader, serializer, remoteHandler), new BinaryConverterStream(writer, serializer, remoteHandler), authenticationHandler) { }