Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F1263149
notifier.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
595 B
Referenced Files
None
Subscribers
None
notifier.ts
View Options
import
{
WebSocketServer
,
WebSocket
}
from
"ws"
;
export
function
make_notifier
(
port
:
number
)
{
const
server
=
new
WebSocketServer
({
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
.
toString
()
);
return
function
notify
(
message
:
string
)
{
sockets
.
forEach
((
s
)
=>
s
.
send
(
message
));
};
}
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Fri, Jan 24, 16:50 (10 h, 43 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
599027
Default Alt Text
notifier.ts (595 B)
Attached To
Mode
rSGEN sealgen
Attached
Detach File
Event Timeline
Log In to Comment