Ejemplo n.º 1
0
 public void Startup()
 {
     if (_is_up)
     {
         return;
     }
     _is_up = true;
     try
     {
         UpdateCommandsAndEvents();
         _server = new WebSocketServer(Port, UseSsl)
         {
         };
         if (UseSsl)
         {
             var rawcert = AssemblyExtensions.GetEmbeddedResourceBytes(typeof(OsmpServer).Assembly, "inton.pfx");
             _server.SslConfiguration.ServerCertificate = new X509Certificate2(rawcert, "inton");
         }
         _server.AddWebSocketService(ServiceUri, CreateSession);
         _server.Start();
     }
     catch (Exception e)
     {
         this.Log(LogLevel.ERROR, s => s.AppendFormat("Startup failed\n" + e.PrettyPrint()));
         Shutdown(); // make sure to shut the server down if startup failed partially
     }
     if (StatusChanged != null)
     {
         StatusChanged(this);
     }
 }