コード例 #1
0
        private void InitServiceInternal(int servicePort, TcpServiceCom service)
        {
            this.connectionType         = ConnectionType.Service;
            service.Logger              = this.logger;
            service.ReceiveBufferSize   = this.ReceiveBufferSize;
            service.SendBufferSize      = this.SendBufferSize;
            service.AdjustSocketHandler = this.AdjustSocketHandler;


            SubscribeCommunicationEvents(service);

            service.Init(servicePort);
            this.communication = service;

            if (LogDataStream)
            {
                dataStreamLogger.Init(this, "Service-" + servicePort, Config != null ? Config.Root : null);
            }

            string errMsg;

            if (this.communication.Connect(out errMsg))
            {
                logger.Info(string.Format("Tcp service established on port {0}", servicePort));
            }
            else
            {
                throw new InvalidOperationException(errMsg);
            }
        }
コード例 #2
0
        private void InitService(XElement securityXml, bool isSecurityEnabled, int servicePort)
        {
            TcpServiceCom service;

            if (isSecurityEnabled)
            {
                var secureService = new SecureTcpServer();
                secureService.CertificateName           = securityXml.GetConfigParameterValue <string>(ConfigParamCertificateName);
                secureService.ClientCertificateRequired = securityXml.GetConfigParameterValueOrDefault <bool>(false, ConfigParamClientCertificateRequired);
                service = secureService;
            }
            else
            {
                service = new TcpServiceCom();
            }
            InitServiceInternal(servicePort, service);
        }