int swoole_websocket_onHandshake(swListenPort *port, http_context *ctx) { #if PHP_MAJOR_VERSION < 7 TSRMLS_FETCH_FROM_CTX(sw_thread_ctx ? sw_thread_ctx : NULL); #endif int fd = ctx->fd; int ret = websocket_handshake(port, ctx); if (ret == SW_ERR) { swServer_tcp_close(SwooleG.serv, fd, 1); } else { swoole_websocket_onOpen(ctx); } //free client data if (!ctx->end) { swoole_http_context_free(ctx TSRMLS_CC); } return SW_OK; }
int swoole_websocket_onHandshake(swoole_http_client *client) { #if PHP_MAJOR_VERSION < 7 TSRMLS_FETCH_FROM_CTX(sw_thread_ctx ? sw_thread_ctx : NULL); #endif int fd = client->fd; int ret = websocket_handshake(client); if (ret == SW_ERR) { SwooleG.serv->factory.end(&SwooleG.serv->factory, fd); } else { swoole_websocket_onOpen(client); } //free client data if (!client->end) { swoole_http_request_free(client TSRMLS_CC); } return SW_OK; }