Recording Studio ‐ WebSockets - ddpalacios/home-server GitHub Wiki
In order to record audio, the audio bytes must be sent to the server. Long polling can be efficient but it could lead to overhead. Websockets provides a consistent connection, avoids repetitive HTTP handshakes, Reduces latency and bandwidth usage, and is ideal for high-frequency, interactive use cases (e.g. chat, gaming, IoT)
Tasks:
- Create Websocket.h/c files
- initialize websocket protocol by generating accept key
- determine if buffer is websocket frame
- decode websocket buffer
- dynamically store data into array
psuedocode
buf = SSL_read( ... )
if ( GET )
if ( route == '/start_websocket') {
int success = initialize_websocket_connection( ... )
if (! success ) {
SSL_Write ("Could not establish websocket connection" )
}
}
if (route == '/stop_websocket') {
int success = close_websocket_connection();
if (!success) {
SSL_Write ("ERROR has occured closing connection" )
}
}
if (is_websocket_buffer (buffer) ) {
char* websocket_message = read_websocket_buffer(buf);
collect_message(websocket_message)
}