public FabricTransportMessageHandlerBroker(
     IFabricTransportMessageHandler service,
     IFabricTransportConnectionHandler nativeConnectionHandler)
 {
     this.service = service;
     this.nativeConnectionHandler = nativeConnectionHandler;
 }
 internal static extern IFabricTransportListener CreateFabricTransportListener(
     ref Guid iid,
     [In] IntPtr transportSettingsPtr,
     [In] IntPtr listenerAddressPtr,
     [In, MarshalAs(UnmanagedType.Interface)] IFabricTransportMessageHandler messageHandler,
     [In, MarshalAs(UnmanagedType.Interface)] IFabricTransportConnectionHandler clientConnectionHandler,
     [In, MarshalAs(UnmanagedType.Interface)] IFabricTransportMessageDisposer messageMessageDisposer
     );
        public FabricTransportListener(
            FabricTransportSettings transportSettings,
            FabricTransportListenerAddress listenerAddress,
            IFabricTransportMessageHandler serviceImplementation,
            IFabricTransportConnectionHandler remotingConnectionHandler)
        {
            //TODO: Remove this address update  after Bug :1225032 gets resolved
            //Update the Address Path if Settings is Secure
            var isNotSecureEndpoint = transportSettings.SecurityCredentials.CredentialType.Equals(CredentialType.None);

            listenerAddress.Path = !isNotSecureEndpoint
                ? string.Format(CultureInfo.InvariantCulture, "{0}-{1}", listenerAddress.Path, Helper.Secure)
                : listenerAddress.Path;

            Utility.WrapNativeSyncInvokeInMTA(
                () =>
                this.CreateNativeListener(serviceImplementation, transportSettings, listenerAddress,
                                          remotingConnectionHandler),
                "FabricTransportListener");
        }
        private void CreateNativeListener(
            IFabricTransportMessageHandler contract,
            FabricTransportSettings transportSettings,
            FabricTransportListenerAddress listenerAddress,
            IFabricTransportConnectionHandler connectionHandler)
        {
            var iid = typeof(NativeServiceCommunication.IFabricServiceCommunicationListener).GetTypeInfo().GUID;

            using (var pin = new PinCollection())
            {
                var nativeTransportSettings = transportSettings.ToNative(pin);
                var nativeListenerAddress   = listenerAddress.ToNative(pin);
                var nativeConnectionHandler = new FabricTransportServiceConnectionHandlerBroker(connectionHandler);
                var messageHandler          = new FabricTransportMessageHandlerBroker(contract, connectionHandler);
                this.nativeListner = NativeServiceCommunication.CreateServiceCommunicationListener(
                    ref iid,
                    nativeTransportSettings,
                    nativeListenerAddress,
                    messageHandler,
                    nativeConnectionHandler);
            }
        }
 public FabricTransportServiceConnectionHandlerBroker(IFabricTransportConnectionHandler serviceConnectionHandler)
 {
     this.connectionHandler = serviceConnectionHandler;
 }