@@ -17,7 +17,7 @@ DEFINE_LOGGER(QuicTransportStream, "QuicTransportStream");
17
17
18
18
Nan::Persistent<v8::Function> QuicTransportStream::s_constructor;
19
19
20
- const int uuidSizeInByte = 16 ;
20
+ const int uuidSizeInBytes = 16 ;
21
21
22
22
QuicTransportStream::QuicTransportStream ()
23
23
: QuicTransportStream(nullptr )
@@ -70,7 +70,6 @@ NAN_MODULE_INIT(QuicTransportStream::init)
70
70
71
71
Nan::SetPrototypeMethod (tpl, " write" , write);
72
72
Nan::SetPrototypeMethod (tpl, " addDestination" , addDestination);
73
- // Nan::SetPrototypeMethod(tpl, "write", write);
74
73
75
74
s_constructor.Reset (Nan::GetFunction (tpl).ToLocalChecked ());
76
75
Nan::Set (target, Nan::New (" QuicTransportStream" ).ToLocalChecked (), Nan::GetFunction (tpl).ToLocalChecked ());
@@ -89,13 +88,14 @@ NAN_METHOD(QuicTransportStream::newInstance)
89
88
info.GetReturnValue ().Set (info.This ());
90
89
}
91
90
92
- NAN_METHOD (QuicTransportStream::write){
93
- if (info.Length ()<2 ){
91
+ NAN_METHOD (QuicTransportStream::write)
92
+ {
93
+ if (info.Length () < 2 ) {
94
94
Nan::ThrowTypeError (" Data is not provided." );
95
95
return ;
96
96
}
97
97
QuicTransportStream* obj = Nan::ObjectWrap::Unwrap<QuicTransportStream>(info.Holder ());
98
- uint8_t * buffer= (uint8_t *)node::Buffer::Data (info[0 ]->ToObject ());
98
+ uint8_t * buffer = (uint8_t *)node::Buffer::Data (info[0 ]->ToObject ());
99
99
unsigned int length = info[1 ]->Uint32Value ();
100
100
obj->m_stream ->Write (buffer, length);
101
101
info.GetReturnValue ().Set (info.This ());
@@ -133,14 +133,14 @@ void QuicTransportStream::MaybeReadContentSessionId()
133
133
{
134
134
if (!m_receivedContentSessionId) {
135
135
// Match to a content session.
136
- if (m_stream->ReadableBytes () > 0 && m_stream->ReadableBytes () < uuidSizeInByte ) {
136
+ if (m_stream->ReadableBytes () > 0 && m_stream->ReadableBytes () < uuidSizeInBytes ) {
137
137
ELOG_ERROR (" No enough data to get content session ID." );
138
138
m_stream->Close ();
139
139
return ;
140
140
}
141
- uint8_t * data = new uint8_t [uuidSizeInByte ];
142
- m_stream->Read (data, uuidSizeInByte );
143
- m_contentSessionId = std::vector<uint8_t >(data, data + uuidSizeInByte );
141
+ uint8_t * data = new uint8_t [uuidSizeInBytes ];
142
+ m_stream->Read (data, uuidSizeInBytes );
143
+ m_contentSessionId = std::vector<uint8_t >(data, data + uuidSizeInBytes );
144
144
m_receivedContentSessionId = true ;
145
145
m_asyncOnContentSessionId.data = this ;
146
146
uv_async_send (&m_asyncOnContentSessionId);
@@ -150,7 +150,8 @@ void QuicTransportStream::MaybeReadContentSessionId()
150
150
}
151
151
}
152
152
153
- NAUV_WORK_CB (QuicTransportStream::onData){
153
+ NAUV_WORK_CB (QuicTransportStream::onData)
154
+ {
154
155
Nan::HandleScope scope;
155
156
QuicTransportStream* obj = reinterpret_cast <QuicTransportStream*>(async->data );
156
157
if (obj == nullptr ) {
@@ -185,15 +186,15 @@ NAUV_WORK_CB(QuicTransportStream::onContentSessionId)
185
186
if (onEventLocal->IsFunction ()) {
186
187
v8::Local<v8::Function> eventCallback = onEventLocal.As <Function>();
187
188
Nan::AsyncResource* resource = new Nan::AsyncResource (Nan::New<v8::String>(" oncontentsessionid" ).ToLocalChecked ());
188
- Local<Value> args[]={ Nan::CopyBuffer ((char *)obj->m_contentSessionId .data (),uuidSizeInByte ).ToLocalChecked ()};
189
+ Local<Value> args[] = { Nan::CopyBuffer ((char *)obj->m_contentSessionId .data (), uuidSizeInBytes ).ToLocalChecked () };
189
190
resource->runInAsyncScope (Nan::GetCurrentContext ()->Global (), eventCallback, 1 , args);
190
191
}
191
192
}
192
193
}
193
194
194
195
void QuicTransportStream::SignalOnData ()
195
196
{
196
- if (!m_isPiped){
197
+ if (!m_isPiped) {
197
198
m_asyncOnData.data = this ;
198
199
uv_async_send (&m_asyncOnData);
199
200
return ;
0 commit comments