예제 #1
0
FString FWebSocketServer::Info()
{
#if !PLATFORM_HTML5
	return FString::Printf(TEXT("%s:%i"), ANSI_TO_TCHAR(lws_canonical_hostname(Context)), ServerPort);
#else 
	return FString(TEXT("NOT SUPPORTED"));
#endif
}
int
callback_lws_status(struct lws *wsi, enum lws_callback_reasons reason,
                    void *user, void *in, size_t len)
{
    struct per_session_data__lws_status *pss =
        (struct per_session_data__lws_status *)user, **pp;
    char name[128], rip[128];
    int m;

    switch (reason) {

    case LWS_CALLBACK_PROTOCOL_INIT:
        /*
         * Prepare the static server info
         */
        server_info_len = sprintf((char *)server_info,
                                  "\"version\":\"%s\","
                                  " \"hostname\":\"%s\"",
                                  lws_get_library_version(),
                                  lws_canonical_hostname(
                                      lws_get_context(wsi)));
        break;

    case LWS_CALLBACK_ESTABLISHED:
        /*
         * we keep a linked list of live pss, so we can walk it
         */
        pss->last = 0;
        pss->list = list;
        list = pss;
        live_wsi++;
        lws_get_peer_addresses(wsi, lws_get_socket_fd(wsi), name,
                               sizeof(name), rip, sizeof(rip));
        sprintf(pss->ip, "%s (%s)", name, rip);
        gettimeofday(&pss->tv_established, NULL);
        strcpy(pss->user_agent, "unknown");
        lws_hdr_copy(wsi, pss->user_agent, sizeof(pss->user_agent),
                     WSI_TOKEN_HTTP_USER_AGENT);
        update_status(wsi, pss);
        break;

    case LWS_CALLBACK_SERVER_WRITEABLE:
        m = lws_write(wsi, (unsigned char *)cache + LWS_PRE, cache_len,
                      LWS_WRITE_TEXT);
        if (m < server_info_len) {
            lwsl_err("ERROR %d writing to di socket\n", m);
            return -1;
        }
        break;

    case LWS_CALLBACK_CLOSED:
        pp = &list;
        while (*pp) {
            if (*pp == pss) {
                *pp = pss->list;
                pss->list = NULL;
                live_wsi--;
                break;
            }
            pp = &((*pp)->list);
        }

        update_status(wsi, pss);
        break;

    default:
        break;
    }

    return 0;
}
예제 #3
0
LWS_VISIBLE LWS_EXTERN const char *
libwebsocket_canonical_hostname(struct lws_context *context)
{
    return lws_canonical_hostname(context);
}
예제 #4
0
FString FJavascriptWebSocketServer::Info()
{
	return FString(ANSI_TO_TCHAR(lws_canonical_hostname(Context)));
}