Skip to content

Commit 490043c

Browse files
committed
feat: add isMonitoringSockets getter to Easy class
1 parent f6d46de commit 490043c

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1212
### Added
1313
- Added back prebuilt binaries for:
1414
- Electron v3, v4 and v5
15+
- Added `isMonitoringSockets` boolean readonly property to `Easy` instances, it is `true`
16+
when `monitorSocketEvents` has been called on that `Easy` instance.
1517
### Changed
1618

1719
## [2.1.1] - 2020-04-28

src/Easy.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -996,11 +996,15 @@ NAN_MODULE_INIT(Easy::Initialize) {
996996
// static methods
997997
Nan::SetMethod(tmpl, "strError", Easy::StrError);
998998

999+
// Instance accessors
9991000
Nan::SetAccessor(proto, Nan::New("id").ToLocalChecked(), Easy::IdGetter, 0,
10001001
v8::Local<v8::Value>(), v8::DEFAULT, v8::ReadOnly);
10011002
Nan::SetAccessor(proto, Nan::New("isInsideMultiHandle").ToLocalChecked(),
10021003
Easy::IsInsideMultiHandleGetter, 0, v8::Local<v8::Value>(), v8::DEFAULT,
10031004
v8::ReadOnly);
1005+
Nan::SetAccessor(proto, Nan::New("isMonitoringSockets").ToLocalChecked(),
1006+
Easy::IsMonitoringSocketsGetter, 0, v8::Local<v8::Value>(), v8::DEFAULT,
1007+
v8::ReadOnly);
10041008

10051009
Easy::constructor.Reset(tmpl);
10061010

@@ -1048,6 +1052,12 @@ NAN_GETTER(Easy::IsInsideMultiHandleGetter) {
10481052
info.GetReturnValue().Set(Nan::New(obj->isInsideMultiHandle));
10491053
}
10501054

1055+
NAN_GETTER(Easy::IsMonitoringSocketsGetter) {
1056+
Easy* obj = Nan::ObjectWrap::Unwrap<Easy>(info.This());
1057+
1058+
info.GetReturnValue().Set(Nan::New(obj->isMonitoringSockets));
1059+
}
1060+
10511061
NAN_METHOD(Easy::SetOpt) {
10521062
Nan::HandleScope scope;
10531063

src/Easy.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ class Easy : public Nan::ObjectWrap {
5555
bool isCbProgressAlreadyAborted =
5656
false; // we need this flag because of
5757
// https://github.com/curl/curl/commit/907520c4b93616bddea15757bbf0bfb45cde8101
58-
bool isMonitoringSockets = false;
5958

6059
int32_t readDataFileDescriptor = -1; // READDATA sets that
6160
curl_off_t readDataOffset = -1; // SEEKDATA sets that
@@ -77,6 +76,7 @@ class Easy : public Nan::ObjectWrap {
7776
// members
7877
CURL* ch;
7978
bool isInsideMultiHandle = false;
79+
bool isMonitoringSockets = false;
8080
bool isOpen = true;
8181

8282
// used to return callback errors when inside Multi interface
@@ -92,6 +92,7 @@ class Easy : public Nan::ObjectWrap {
9292
static NAN_METHOD(New);
9393
static NAN_GETTER(IdGetter);
9494
static NAN_GETTER(IsInsideMultiHandleGetter);
95+
static NAN_GETTER(IsMonitoringSocketsGetter);
9596
static NAN_METHOD(SetOpt);
9697
static NAN_METHOD(GetInfo);
9798
static NAN_METHOD(Send);

0 commit comments

Comments
 (0)