Kaynağa Gözat

Use new server config

Stefan Profanter 7 yıl önce
ebeveyn
işleme
ace26ed6ea
1 değiştirilmiş dosya ile 5 ekleme ve 8 silme
  1. 5 8
      examples/server_certificate.c

+ 5 - 8
examples/server_certificate.c

@@ -46,14 +46,11 @@ static void stopHandler(int sign) {
 int main(int argc, char** argv) {
     signal(SIGINT, stopHandler); /* catches ctrl-c */
 
-    UA_ServerConfig config = UA_ServerConfig_standard;
-    UA_ServerNetworkLayer nl = UA_ServerNetworkLayerTCP(UA_ConnectionConfig_standard, 16664);
-    config.networkLayers = &nl;
-    config.networkLayersSize = 1;
+    UA_ServerConfig *config = UA_ServerConfig_new_default();
 
     /* load certificate */
-    config.serverCertificate = loadCertificate();
-    if(config.serverCertificate.length > 0)
+    config->serverCertificate = loadCertificate();
+    if(config->serverCertificate.length > 0)
         UA_LOG_INFO(logger, UA_LOGCATEGORY_SERVER, "Certificate loaded");
 
 
@@ -62,10 +59,10 @@ int main(int argc, char** argv) {
     UA_StatusCode retval = UA_Server_run(server, &running);
 
     /* deallocate certificate's memory */
-    UA_ByteString_deleteMembers(&config.serverCertificate);
+    UA_ByteString_deleteMembers(&config->serverCertificate);
 
     UA_Server_delete(server);
-    nl.deleteMembers(&nl);
+    UA_ServerConfig_delete(config);
 
     return (int)retval;
 }