Esempio n. 1
0
        public void Start()
        {
            CoAP.Log.LogManager.Level = CoAP.Log.LogLevel.Error;
            _ProcessRequestsThread    = new Thread(new ThreadStart(ProcessRequests));
            if (_ProcessRequestsThread.Name == null)
            {
                _ProcessRequestsThread.Name = "ProcessRequestsThread";
            }
            _ProcessRequestsThread.IsBackground = true;
            _ProcessRequestsThread.Start();
            if (!SecureOnly)
            {
                _CoapServer.AddEndPoint(new CoAPEndPoint(new FlowChannel(_Port), CoapConfig.Default));
            }
            FlowSecureChannel secure = new FlowSecureChannel(_Port + 1);

            if (System.IO.File.Exists("LWM2MBootsrap.pem"))
            {
                secure.CertificateFile = "LWM2MBootsrap.pem";
            }
            secure.PSKIdentities = _PSKIdentities;
            secure.SupportedCipherSuites.Add(TCipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8);
            secure.SupportedCipherSuites.Add(TCipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256);
            secure.SupportedCipherSuites.Add(TCipherSuite.TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256);
            secure.SupportedCipherSuites.Add(TCipherSuite.TLS_PSK_WITH_AES_128_CCM_8);
            secure.SupportedCipherSuites.Add(TCipherSuite.TLS_PSK_WITH_AES_128_CBC_SHA256);
            secure.ValidatePSK += new EventHandler <ValidatePSKEventArgs>(ValidatePSK);
            _CoapServer.AddEndPoint(new CoAPEndPoint(secure, CoapConfig.Default));
            _CoapServer.Start();
        }
Esempio n. 2
0
        public void Start()
        {
            CoAP.Log.LogManager.Level = CoAP.Log.LogLevel.Error;
            int port;
            string apiPort = System.Configuration.ConfigurationManager.AppSettings["APIPort"];
            if (!int.TryParse(apiPort, out port))
                port = 14080;
            _ProcessRequestsThread = new Thread(new ThreadStart(ProcessRequests));
            if (_ProcessRequestsThread.Name == null)
                _ProcessRequestsThread.Name = "ProcessRequestsThread";
            _ProcessRequestsThread.IsBackground = true;
            _ProcessRequestsThread.Start();
            if (_CoapServer == null)
            {
                _CoapServer = new CoapServer();
                _CoapServer.MessageDeliverer = this;
                if (!SecureOnly)
                    _CoapServer.AddEndPoint(new CoAPEndPoint(new FlowChannel(Port), CoapConfig.Default));
                _SecureChannel = new FlowSecureChannel(Port + 1);
                if (System.IO.File.Exists("LWM2MServer.pem"))
                {
                    _SecureChannel.CertificateFile = "LWM2MServer.pem";
                }
                _SecureChannel.PSKIdentities = _PSKIdentities;
                _SecureChannel.SupportedCipherSuites.Add(TCipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8);
                _SecureChannel.SupportedCipherSuites.Add(TCipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256);
                _SecureChannel.SupportedCipherSuites.Add(TCipherSuite.TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256);
                _SecureChannel.SupportedCipherSuites.Add(TCipherSuite.TLS_PSK_WITH_AES_128_CCM_8);
                _SecureChannel.SupportedCipherSuites.Add(TCipherSuite.TLS_PSK_WITH_AES_128_CBC_SHA256);
                _SecureChannel.ValidatePSK += new EventHandler<ValidatePSKEventArgs>(ValidatePSK);
                _CoapServer.AddEndPoint(new CoAPEndPoint(_SecureChannel, CoapConfig.Default));
            }
            _CoapServer.Start();

            ServiceEventMessage message = new ServiceEventMessage();
            Imagination.Model.LWM2MServer lwm2mServer = new Imagination.Model.LWM2MServer();
            lwm2mServer.Url = ServiceConfiguration.ExternalUri.ToString();
            message.AddParameter("Server", lwm2mServer);
            BusinessLogicFactory.ServiceMessages.Publish("LWM2MServer.Start", message, TMessagePublishMode.Confirms);

            _ServerEndPoint = string.Concat("net.tcp://", ServiceConfiguration.Hostname, ":", port.ToString(), "/LWM2MServerService");
            if (_NativeServerAPI == null)
                _NativeServerAPI = new NativeIPCServer(AddressFamily.InterNetwork,port);
            _NativeServerAPI.Start();
            if (_NativeServerAPIv6 == null)
                _NativeServerAPIv6 = new NativeIPCServer(AddressFamily.InterNetworkV6, port);
            _NativeServerAPIv6.Start();
            //if (_ServiceHost != null)
            //    _ServiceHost.Close();
            //_ServiceHost = new ServiceHost(typeof(Imagination.Service.ServerAPI));
            //ServiceThrottlingBehavior throttle = _ServiceHost.Description.Behaviors.Find<ServiceThrottlingBehavior>();
            //if (throttle == null)
            //{
            //    throttle = new ServiceThrottlingBehavior
            //    {
            //        MaxConcurrentCalls = 100,
            //        MaxConcurrentSessions = 100,
            //        MaxConcurrentInstances = int.MaxValue
            //    };
            //    _ServiceHost.Description.Behaviors.Add(throttle);
            //}
            //else
            //{
            //    throttle.MaxConcurrentCalls = 100;
            //    throttle.MaxConcurrentSessions = 100;
            //    throttle.MaxConcurrentInstances = int.MaxValue;
            //}
            //NetTcpBinding netTcpBinding = new NetTcpBinding();
            //_ServiceHost.AddServiceEndpoint(typeof(Imagination.Service.ILWM2MServerService), netTcpBinding, _ServerEndPoint);
            ////int newLimit = _ServiceHost.IncrementManualFlowControlLimit(100);
            //_ServiceHost.Open();
        }
Esempio n. 3
0
        public void Start()
        {
            CoAP.Log.LogManager.Level = CoAP.Log.LogLevel.Error;
            int    port;
            string apiPort = System.Configuration.ConfigurationManager.AppSettings["APIPort"];

            if (!int.TryParse(apiPort, out port))
            {
                port = 14080;
            }
            _ProcessRequestsThread = new Thread(new ThreadStart(ProcessRequests));
            if (_ProcessRequestsThread.Name == null)
            {
                _ProcessRequestsThread.Name = "ProcessRequestsThread";
            }
            _ProcessRequestsThread.IsBackground = true;
            _ProcessRequestsThread.Start();
            if (_CoapServer == null)
            {
                _CoapServer = new CoapServer();
                _CoapServer.MessageDeliverer = this;
                if (!SecureOnly)
                {
                    _CoapServer.AddEndPoint(new CoAPEndPoint(new FlowChannel(Port), CoapConfig.Default));
                }
                _SecureChannel = new FlowSecureChannel(Port + 1);
                if (System.IO.File.Exists("LWM2MServer.pem"))
                {
                    _SecureChannel.CertificateFile = "LWM2MServer.pem";
                }
                _SecureChannel.PSKIdentities = _PSKIdentities;
                _SecureChannel.SupportedCipherSuites.Add(TCipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8);
                _SecureChannel.SupportedCipherSuites.Add(TCipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256);
                _SecureChannel.SupportedCipherSuites.Add(TCipherSuite.TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256);
                _SecureChannel.SupportedCipherSuites.Add(TCipherSuite.TLS_PSK_WITH_AES_128_CCM_8);
                _SecureChannel.SupportedCipherSuites.Add(TCipherSuite.TLS_PSK_WITH_AES_128_CBC_SHA256);
                _SecureChannel.ValidatePSK += new EventHandler <ValidatePSKEventArgs>(ValidatePSK);
                _CoapServer.AddEndPoint(new CoAPEndPoint(_SecureChannel, CoapConfig.Default));
            }
            _CoapServer.Start();

            ServiceEventMessage message = new ServiceEventMessage();

            Imagination.Model.LWM2MServer lwm2mServer = new Imagination.Model.LWM2MServer();
            lwm2mServer.Url = ServiceConfiguration.ExternalUri.ToString();
            message.AddParameter("Server", lwm2mServer);
            BusinessLogicFactory.ServiceMessages.Publish("LWM2MServer.Start", message, TMessagePublishMode.Confirms);


            _ServerEndPoint = string.Concat("net.tcp://", ServiceConfiguration.Hostname, ":", port.ToString(), "/LWM2MServerService");
            if (_NativeServerAPI == null)
            {
                _NativeServerAPI = new NativeIPCServer(AddressFamily.InterNetwork, port);
            }
            _NativeServerAPI.Start();
            if (_NativeServerAPIv6 == null)
            {
                _NativeServerAPIv6 = new NativeIPCServer(AddressFamily.InterNetworkV6, port);
            }
            _NativeServerAPIv6.Start();
            //if (_ServiceHost != null)
            //    _ServiceHost.Close();
            //_ServiceHost = new ServiceHost(typeof(Imagination.Service.ServerAPI));
            //ServiceThrottlingBehavior throttle = _ServiceHost.Description.Behaviors.Find<ServiceThrottlingBehavior>();
            //if (throttle == null)
            //{
            //    throttle = new ServiceThrottlingBehavior
            //    {
            //        MaxConcurrentCalls = 100,
            //        MaxConcurrentSessions = 100,
            //        MaxConcurrentInstances = int.MaxValue
            //    };
            //    _ServiceHost.Description.Behaviors.Add(throttle);
            //}
            //else
            //{
            //    throttle.MaxConcurrentCalls = 100;
            //    throttle.MaxConcurrentSessions = 100;
            //    throttle.MaxConcurrentInstances = int.MaxValue;
            //}
            //NetTcpBinding netTcpBinding = new NetTcpBinding();
            //_ServiceHost.AddServiceEndpoint(typeof(Imagination.Service.ILWM2MServerService), netTcpBinding, _ServerEndPoint);
            ////int newLimit = _ServiceHost.IncrementManualFlowControlLimit(100);
            //_ServiceHost.Open();
        }
Esempio n. 4
0
 public void Start()
 {
     CoAP.Log.LogManager.Level = CoAP.Log.LogLevel.Error;
     _ProcessRequestsThread = new Thread(new ThreadStart(ProcessRequests));
     if (_ProcessRequestsThread.Name == null)
         _ProcessRequestsThread.Name = "ProcessRequestsThread";
     _ProcessRequestsThread.IsBackground = true;
     _ProcessRequestsThread.Start();
     if (!SecureOnly)
         _CoapServer.AddEndPoint(new CoAPEndPoint(new FlowChannel(_Port), CoapConfig.Default));
     FlowSecureChannel secure = new FlowSecureChannel(_Port+1);
     if (System.IO.File.Exists("LWM2MBootstrap.pem"))
     {
         secure.CertificateFile = "LWM2MBootstrap.pem";
     }
     secure.PSKIdentities = _PSKIdentities;
     secure.SupportedCipherSuites.Add(TCipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8);
     secure.SupportedCipherSuites.Add(TCipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256);
     secure.SupportedCipherSuites.Add(TCipherSuite.TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256);
     secure.SupportedCipherSuites.Add(TCipherSuite.TLS_PSK_WITH_AES_128_CCM_8);
     secure.SupportedCipherSuites.Add(TCipherSuite.TLS_PSK_WITH_AES_128_CBC_SHA256);
     secure.ValidatePSK += new EventHandler<ValidatePSKEventArgs>(ValidatePSK);
     _CoapServer.AddEndPoint(new CoAPEndPoint(secure, CoapConfig.Default));
     _CoapServer.Start();
 }