npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nativescript-stomp-connector

v1.1.2-beta

Published

Your awesome NativeScript plugin.

Downloads

6

Readme

:warning: This plugin is under construction.

nativescript-stomp-connector

Client connector for Websocket through STOMP protocol.

This plugin use the NaikSoftware/StompProtocolAndroid for Android and WrathChaos/StompClientLib for iOS.

#TODO

  • [ ] Migrate to Nativescript 7;
  • [ ] Add nativescript core demo;
  • [ ] Add repository for service example using spring boot to this README;
  • [ ] Add Troubleshooting to this README;
  • [ ] Improve API documentation;

Installation

Run nativescript cli to install this plugin

tns plugin add nativescript-stomp-connector

Usage

Core

Under construction

TypeScript

Import the StompConnector in your component

import { StompConnector, StompMessage } from 'nativescript-stomp-connector';

Call Connnect

private _wsUrl = "ws://{your-server}:{port}/{path}/websocket";
public stompClient: StompConnector;

constructor(private _changeDetectorRef: ChangeDetectorRef) {
	this.stompClient = new StompConnector();
}

public connect(): void {
	this.stompClient.connect({
		brokerURL: this._wsUrl,
		onConnect: () => {
			console.log(`==== CONNECTED ===`);
		},
		onReconnect: () => {
			console.log(`==== RECONNECTED ===`);
		},
		onStompError: (error) => {
			console.error(error);
		},
		onDisconnect: () => {
			console.log(`==== DISCONNECTED ===`);
		},
		debug: (msg: string) => {
			console.log(msg);
		}
	} as StompConfig);
}

Disconnect

public disconnect(): void {
	this.stompClient.disconnect();
}

Subscribe to topic

public subscribeToTopic(): void {
	this.stompClient.topic('/topic/broadcast', (response: StompMessage) => { console.dir(response); });
}

Unsubscribe to topic

unsubscribeToTopic() {
	this.stompClient.unsubscribe('/topic/broadcast', () => console.log("Unsubscribed successfully"));
}

Send message

sendMessageAsObject() {
	this.stompClient.send({ 
		message: JSON.stringify({ content: this.messageContent }), 
		destination: '/app/greetings',
		withHeaders: { "content-type": "application/json" }
	}, () => { console.log('Message just sent!'); });
}

API

StompConnector

connect(config)

This function will connect to your stomp broker and call the callback onConnect after finish it;

disconnect()

Disconnect the stomp broker;

isConnected()

Return true if broker is connected;

topic(destination, successCallBack, failCallBack)

Subscribe to topic passing destination and successCallBack as mandatory parameters.

unsubscribe(destination, successCallback)

Unsubscribe to topic by destination.

send(request, successCallBack, failCallBack)

Send messsage to stomp broker;

StompConfiguration

| Property | Default | Description | | --- | --- | --- | | brokerURL | empty | The websocket url. Mandatory | | autoReconnect | false | Android only for now | | reconnectDelay | 5000 | The delay between attempts to reconnect in ms | | connectHeaders | empty | [key: string]: string; > example: { 'content-type': 'application/json' } | | onConnect() | Function | callback called on websocket connection successful | | onReconnect() | Function | callback called on server auto reconnected. Android only for now | | onDisconnect() | Function | callback called on webscoket disconnect | | onStompError(error) | Function | called when got an exception | | debug(msg) | Function | Use this to have more logs |

Native Component

| Android | iOS | |:-----------------------|:---------| | NaikSoftware/StompProtocolAndroid | WrathChaos/StompClientLib |

Author

Daniel Borba, [email protected]

License

Apache License Version 2.0, January 2004