Skip to content

Commit

Permalink
Fixed frame type in web socket server example
Browse files Browse the repository at this point in the history
  • Loading branch information
kala13x committed May 24, 2023
1 parent c1ccece commit 5cf8c2c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions examples/ws-server.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,13 @@ int send_pong(xapi_data_t *pData)
return XAPI_EnableEvent(pData, XPOLLOUT);
}

int send_response(xapi_data_t *pData, const uint8_t *pPayload, size_t nLength)
int send_response(xapi_data_t *pData, const uint8_t *pPayload, size_t nLength, xws_frame_type_t eType)
{
session_data_t *pSession = (session_data_t*)pData->pSessionData;
xws_status_t status;
xws_frame_t frame;

status = XWebFrame_Create(&frame, pPayload, nLength, XWS_TEXT, XTRUE);
status = XWebFrame_Create(&frame, pPayload, nLength, eType, XTRUE);
if (status != XWS_ERR_NONE)
{
xloge("Failed to create WS frame: %s",
Expand Down Expand Up @@ -175,7 +175,7 @@ int handle_frame(xapi_ctx_t *pCtx, xapi_data_t *pData)
xlogn("Payload (%zu bytes): %s", nLength, (const char*)pPayload);

/* Send payload back to the client (echo) */
return send_response(pData, pPayload, nLength);
return send_response(pData, pPayload, nLength, pFrame->eType);
}

int init_session(xapi_ctx_t *pCtx, xapi_data_t *pData)
Expand Down
2 changes: 1 addition & 1 deletion src/xver.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

#define XUTILS_VERSION_MAX 2
#define XUTILS_VERSION_MIN 5
#define XUTILS_BUILD_NUMBER 30
#define XUTILS_BUILD_NUMBER 31

#ifdef __cplusplus
extern "C" {
Expand Down

0 comments on commit 5cf8c2c

Please sign in to comment.