mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
add 'discardAll' parameter to socket:close(...)
This commit is contained in:
parent
20bd7666cd
commit
d2bbd82dbe
3 changed files with 11 additions and 6 deletions
|
|
@ -73,7 +73,7 @@ static int l_connect(lua::State* L) {
|
|||
static int l_close(lua::State* L) {
|
||||
u64id_t id = lua::tointeger(L, 1);
|
||||
if (auto connection = engine->getNetwork().getConnection(id)) {
|
||||
connection->close();
|
||||
connection->close(true);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -400,10 +400,15 @@ public:
|
|||
return readBatch.size();
|
||||
}
|
||||
|
||||
void close() override {
|
||||
if (state != ConnectionState::CLOSED) {
|
||||
shutdown(descriptor, 2);
|
||||
closesocket(descriptor);
|
||||
void close(bool discardAll=false) override {
|
||||
{
|
||||
std::lock_guard lock(mutex);
|
||||
readBatch.clear();
|
||||
|
||||
if (state != ConnectionState::CLOSED) {
|
||||
shutdown(descriptor, 2);
|
||||
closesocket(descriptor);
|
||||
}
|
||||
}
|
||||
if (thread) {
|
||||
thread->join();
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ namespace network {
|
|||
virtual void connect(runnable callback) = 0;
|
||||
virtual int recv(char* buffer, size_t length) = 0;
|
||||
virtual int send(const char* buffer, size_t length) = 0;
|
||||
virtual void close() = 0;
|
||||
virtual void close(bool discardAll=false) = 0;
|
||||
virtual int available() = 0;
|
||||
|
||||
virtual size_t pullUpload() = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue