| 451 | } |
| 452 | |
| 453 | void internal_close_socket( internal_socket_t* socket ) { |
| 454 | if( socket->closing ) |
| 455 | // socket clos process has already started, ignore the request. |
| 456 | return; |
| 457 | else if( socket->wsi ) { |
| 458 | libwebsocket_callback_on_writable(g_context->websocket, socket->wsi); |
| 459 | // TODO: How do we clean up ? |
| 460 | } else if( socket->webrtc ) { |
| 461 | // this will trigger the destruction of the channel and thus the destruction of our socket object. |
| 462 | socket->closing = true; |
| 463 | libwebrtc_close_connection( socket->webrtc ); |
| 464 | } else { |
| 465 | assert( "Destroyed socket passed to close" == NULL ); |
| 466 | } |
| 467 | } |
| 468 | |
| 469 | int internal_write_socket(internal_socket_t* socket, const void *buf, int bufsize) { |
| 470 | if( socket->wsi ) { |