Is your feature request related to a problem? Please describe
I searched the documentation and only found this: https://nginx.org/en/docs/njs/reference.html#s_on
I would like to know when a stream (which would also have to be a session) starts and closes again.
Describe the solution you'd like
It would be nice to have "start" and "close" on the event ".on()" for stream and http.
- start: A connection from the client is incoming (first connection from the client)
- close: The client disconnects
And to be able to identify the session using an “ID”.
async(s: NginxStreamRequest): Promise<void> => {
r.on('start', () => {
const id = s.identifer();
....
});
r.on('close', () => {
const id = s.identifer();
// cleanup somthing
});
}
As an alternative (This is actually a better approach to get “start” as an event.), I could also imagine having to create an event object/function:
stream {
js_import mainstream from /opt/test.js;
...
server {
listen 80;
js_access mainstream.accessAddressStream;
js_session_event mainstream.sessionEvent;
...
}
}
test.js:
const accessAddressStream = async(s: NginxStreamRequest): Promise<void> => {
.....
}
const sessionEvent = async(event: SessionEvent, s: NginxStreamRequest|NginxHTTPRequest, ): Promise<void> => {
const id = s.identifer();
switch(event) {
case SessionEvent.start:
.....
break;
case SessionEvent.start:
.....
break;
}
.....
}
export default {accessAddressStream, sessionEvent};
Is your feature request related to a problem? Please describe
I searched the documentation and only found this: https://nginx.org/en/docs/njs/reference.html#s_on
I would like to know when a stream (which would also have to be a session) starts and closes again.
Describe the solution you'd like
It would be nice to have "start" and "close" on the event ".on()" for stream and http.
And to be able to identify the session using an “ID”.
As an alternative (This is actually a better approach to get “start” as an event.), I could also imagine having to create an event object/function:
test.js: