
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
signalk-client-angular
Advanced tools
Note: This library was generated with Angular CLI version 12.0.0.
SignalKClient is an Angular library to facilitate communication with a Signal K server.
It provides the following classes to interact with Signal K HTTP
and STREAM
APIs as well as exposing STREAM Events
:
api
class for interacting with Signal K HTTP API
stream
class for interacting with Signal K STREAM API
apps
class to enable interaction with applications installed on the Signal K server
NOTE: To connect to a Signal K stream using a web worker use the signalk-worker-angular
library in conjunction with this library.
npm i signalk-worker-angular
From the release of version 1.7.0 the following methods now return an Observable
.
connect()
connectStream()
connectPlayback()
To continue using Promise
s update your code to use the following methods:
connectAsPromise()
connectStreamAsPromise()
connectPlaybackAsPromise()
See below for some Examples below to see how to use this library..
Detailed documentation for using this library can be found on GitHub.
npm install signalk-client-angular
app.module.ts
SignalKClientModule
in your project. import { SignalKClientModule } from 'signalk-client-angular';
app.component.ts
SignalKClient
into your application.import { SignalKClient } from 'signalk-client-angular';
// **** Inject the SignalKClient ****
constructor( public sk: SignalKClient ) {
...
}
The simplest way to get started is to connect to a Signal K server and open a websocket to its data stream.
To do this:
Use connectStream(...)
to connect to the server and open the data stream.
Subscribe to the stream
events to process the received data
Example:
// **** Subscribe to Signal K Stream events ***
this.sk.stream.onConnect.subscribe( e=> {
...handle connection event
});
this.sk.stream.onError.subscribe( e=> {
...handle error event
});
this.sk.stream.onClose.subscribe( e=> {
...handle connection closed event
});
this.sk.stream.onMessage.subscribe( e=> {
...handle message received event
});
// **** CONNECT to Server and open STREAM ****
this.sk.connectStream('192.168.99.100', 80, false, 'self');
Once connected you can then interact with both the STREAM and HTTP APIs in the following ways:
stream
object to interact with the websocket connection. // **** send data to STREAM API ****
this.sk.stream.send({..data..});
api
object to interact Signal K HTTP API path. /signalk/v1/api/
Example:
// **** make HTTP API request ****
this.sk.api.get('vessels/self/navigation/position').subscribe(
response=> { ... },
error=> { ... }
);
If you want to just use the HTTP API or defer the connection to the STREAM API based on user interaction use the connect(..)
method.
Use connect(...)
to connect to the server and perform endpoint discovery.
When you are ready to connect to the STREAM API use openStream()
( or stream.open()
) with a null
or undefined
url parameter. This will cnnect to the discovered stream endpoint.
Example:
// **** Subscribe to Signal K Stream events ***
this.sk.stream.onConnect.subscribe( e=> {
...handle connection event
});
this.sk.stream.onError.subscribe( e=> {
...handle error event
});
this.sk.stream.onClose.subscribe( e=> {
...handle connection closed event
});
this.sk.stream.onMessage.subscribe( e=> {
...handle message received event
});
// **** CONNECT to Signal K Server ****
this.sk.connect('192.168.99.100', 80, false, 'self');
...
this.sk.openStream( null, 'self');
OR
this.sk.stream.open( null, 'self');
By default the connect methods will cause an HTTP request to be sent to the server /signalk
path to discover the server's advertised endpoints.
To interact with the server without using endpoint discovery use the openStream(<hostname>, <port>)
method specifying the host ip address and port.
Note: No HTTP endpoint discovery is performed when using openXX()
methods and specifying a host.
Example:
// **** Subscribe to Signal K Stream events ***
this.sk.stream.onConnect.subscribe( e=> {
...handle connection event
});
this.sk.stream.onError.subscribe( e=> {
...handle error event
});
this.sk.stream.onClose.subscribe( e=> {
...handle connection closed event
});
this.sk.stream.onMessage.subscribe( e=> {
...handle message received event
});
// **** CONNECT to Signal K Server ****
this.sk.openStream('192.168.99.100', 80, false, 'self');
FAQs
Signal K client library for Angular.
The npm package signalk-client-angular receives a total of 5 weekly downloads. As such, signalk-client-angular popularity was classified as not popular.
We found that signalk-client-angular demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.