add 'discardAll' parameter to socket:close(...)
This commit is contained in:
parent
20bd7666cd
commit
d2bbd82dbe
@ -73,7 +73,7 @@ static int l_connect(lua::State* L) {
|
|||||||
static int l_close(lua::State* L) {
|
static int l_close(lua::State* L) {
|
||||||
u64id_t id = lua::tointeger(L, 1);
|
u64id_t id = lua::tointeger(L, 1);
|
||||||
if (auto connection = engine->getNetwork().getConnection(id)) {
|
if (auto connection = engine->getNetwork().getConnection(id)) {
|
||||||
connection->close();
|
connection->close(true);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -400,10 +400,15 @@ public:
|
|||||||
return readBatch.size();
|
return readBatch.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
void close() override {
|
void close(bool discardAll=false) override {
|
||||||
if (state != ConnectionState::CLOSED) {
|
{
|
||||||
shutdown(descriptor, 2);
|
std::lock_guard lock(mutex);
|
||||||
closesocket(descriptor);
|
readBatch.clear();
|
||||||
|
|
||||||
|
if (state != ConnectionState::CLOSED) {
|
||||||
|
shutdown(descriptor, 2);
|
||||||
|
closesocket(descriptor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (thread) {
|
if (thread) {
|
||||||
thread->join();
|
thread->join();
|
||||||
|
|||||||
@ -49,7 +49,7 @@ namespace network {
|
|||||||
virtual void connect(runnable callback) = 0;
|
virtual void connect(runnable callback) = 0;
|
||||||
virtual int recv(char* buffer, size_t length) = 0;
|
virtual int recv(char* buffer, size_t length) = 0;
|
||||||
virtual int send(const 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 int available() = 0;
|
||||||
|
|
||||||
virtual size_t pullUpload() = 0;
|
virtual size_t pullUpload() = 0;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user