Skip to content

Commit 5cf8c2c

Browse files
committed
Fixed frame type in web socket server example
1 parent c1ccece commit 5cf8c2c

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

examples/ws-server.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,13 @@ int send_pong(xapi_data_t *pData)
129129
return XAPI_EnableEvent(pData, XPOLLOUT);
130130
}
131131

132-
int send_response(xapi_data_t *pData, const uint8_t *pPayload, size_t nLength)
132+
int send_response(xapi_data_t *pData, const uint8_t *pPayload, size_t nLength, xws_frame_type_t eType)
133133
{
134134
session_data_t *pSession = (session_data_t*)pData->pSessionData;
135135
xws_status_t status;
136136
xws_frame_t frame;
137137

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

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

181181
int init_session(xapi_ctx_t *pCtx, xapi_data_t *pData)

src/xver.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
#define XUTILS_VERSION_MAX 2
1414
#define XUTILS_VERSION_MIN 5
15-
#define XUTILS_BUILD_NUMBER 30
15+
#define XUTILS_BUILD_NUMBER 31
1616

1717
#ifdef __cplusplus
1818
extern "C" {

0 commit comments

Comments
 (0)