Glib websocket永久自动重试以用于websocket服务器连接示例

时间:2019-05-29 18:16:25

标签: c websocket glib

任何人都可以通过提供glib websocket自动重新连接的示例来帮助您,如果服务器关闭然后又恢复正常的话。

session = soup_session_new_with_options (SOUP_SESSION_SSL_STRICT,     !disable_ssl,
  SOUP_SESSION_SSL_USE_SYSTEM_CA_FILE, TRUE,
  //SOUP_SESSION_SSL_CA_FILE, "/etc/ssl/certs/ca-bundle.crt",
  SOUP_SESSION_HTTPS_ALIASES, https_aliases, NULL);

  logger = soup_logger_new (SOUP_LOGGER_LOG_BODY, -1);
  soup_session_add_feature (session, SOUP_SESSION_FEATURE (logger));
  g_object_unref (logger);

  message = soup_message_new (SOUP_METHOD_GET, server_url);

  g_print ("Connecting to server...\n");

  /* Once connected, we will register */
  soup_session_websocket_connect_async (session, message, NULL, NULL, NULL,
  (GAsyncReadyCallback) on_server_connected, message);
  app_state = SERVER_CONNECTING;

谢谢。

0 个答案:

没有答案