Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F969341
notifier.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
559 B
Referenced Files
None
Subscribers
None
notifier.ts
View Options
import
WebSocket
from
"ws"
;
export
function
make_notifier
(
port
:
number
)
{
const
server
=
new
WebSocket
.
Server
({
port
,
});
let
sockets
:
WebSocket
[]
=
[];
server
.
on
(
"connection"
,
function
(
socket
)
{
sockets
.
push
(
socket
);
// When a socket closes, or disconnects, remove it from the array.
socket
.
on
(
"close"
,
function
()
{
sockets
=
sockets
.
filter
((
s
)
=>
s
!==
socket
);
});
});
console
.
log
(
"build notifier listening on websocket at port "
+
port
);
return
function
notify
(
message
:
string
)
{
sockets
.
forEach
((
s
)
=>
s
.
send
(
message
));
};
}
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Fri, Nov 22, 17:57 (16 h, 50 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
547725
Default Alt Text
notifier.ts (559 B)
Attached To
Mode
rSGEN sealgen
Attached
Detach File
Event Timeline
Log In to Comment