Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
WebSocket service for Angular.js.
bower install angular-ws
angular.module('app', ['ws'])
.config(function (wsProvider) {
wsProvider.setUrl('ws://echo.websocket.org');
})
.controller('WebSocketCtrl', function ($scope, ws, $log) {
ws.on('message', function (event) {
$log.info('New message', event.data);
});
ws.send('custom message');
});
Set the url of the WebSocket.
wsProvider.setUrl('ws://echo.websocket.org');
Set the protocols used by the WebSocket.
wsProvider.setProtocols(['protocol']);
Set a custom transport (example: ReconnectingWebSocket).
wsProvider.setTransport(ReconnectingWebSocket);
Connect the WebSocket, you can provide a custom config.
Note that if you use ws.on
or ws.send
the connection is automatic.
ws.connect({
url: 'ws://echo.websocket.org',
protocols: ['protocol']
})
.then(function () {
$log.debug('WebSocket is connected.');
}, function () {
$log.debug('An error occurs during WebSocket connection.');
});
The base socket object.
ws.baseSocket.onmessage = function (event) {
// event.data ...
}
Get the ready state of the WebSocket.
ws.getReadyState() // WebSocket.CLOSED, WebSocket.OPEN...
Listen an event on the WebSocket, the function is already wrapped in $rootScope.$apply()
.
ws.on('message', function (event) {
$log.info('New message', event.data);
});
Close the connection of the WebSocket.
ws.close();
To be able to test WebSocket in the good way, the module angular-ws-mock will provide you a transparent mock.
MIT
FAQs
WebSocket service for Angular.js.
The npm package angular-ws receives a total of 0 weekly downloads. As such, angular-ws popularity was classified as not popular.
We found that angular-ws demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.