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

cliente-sp-vue

v1.0.1

Published

Conexion al servidor push

Downloads

7

Readme

cliente-sp-vue

Conexion al servidor push

Agregar a tu proyecto

  1. Instala el paquete cliente-sp-vue.

npm install cliente-sp-vue

  1. Instala vuex en tu proyecto y crea tu store, el cual tendra interacion con las alertas recibidas por el wbsocket.
import Vue from "vue";
import Vuex from "vuex";

// Importamos el cliente sp vue que contiene los state y mutation, etc, necesarios para la interacion con el servidor push.
import sp from "cliente-sp-vue"

Vue.use(Vuex);
export default new Vuex.Store({
  state: {
  },
  mutations: {
  },
  actions: {
  },
  getters: {
  },
  modules: {
    // Lo agregamos a un modulo
    sp:sp.moduloSP
  }
  
});
  1. Instala el paquete vue-native-websocket.

npm install vue-native-websocket

  1. Importa el paquete cliente-sp-vue junto con vue-native-websocket. Para mas info.
.
.
.
// Agrega tu store de vuex
import store from "./store";
import sp from "cliente-sp-vue";
import VueNativeSock from "vue-native-websocket";

Vue.use(VueNativeSock, sp.init.ws, {
  // El store para interacion con el paquete vue-native-websocket
  store: store,
  // Mutations 
  mutations: sp.mutations,
  reconnection: true,
  connectManually: true,
  reconnectionDelay: 3000
});

.
.
.
  1. Asigna el id de conexión.
 this.$store.dispatch("asignarId", "SAPYME_ID");
  1. Conecta con el servidor push.
this.$store.dispatch("conectarSocket");
  1. Envio de la notificación. Para mas información ir a Servidor Push
let noti = {        
        titulo: 'Titulo',        
        para:"ID_A_ENVIAR_NOTIFICACION",
        mensaje: 'Mensaje',
        tipo: 'Info',
        datos:[],
        dispositivo:"web"
      };
this.$store.dispatch("enviarNotificacion", noti);

 
  1. Desconectar del servidor push.
this.$store.dispatch("desconetarSocket");

Para la configuración del servicio necesitas las siguientes variables.

  1. Token de servidor push

Lo podras obtener en Servidor Push, en el apartado de sistemas.

  1. Un identificador unico

Cadena string que identifique tu usuario y garantice que sea unico dentro del sistema. Ejemplo TEST-SVANESA

  1. El token del api svanesa

Si tienes una suscripcion vigente de Servidor Push, podras ir a Svanesa y en el apartado tokens.

  1. El id del sistema svanesa a conectar

En el mismo modulo anterior existe la eqtiqueta sistema con un idunico.


NOTA

El archivo de configuracion para el servidor push se encontrara en la raiz del proyecto.

sp.config.js

let token = "sp-000000000-00000-000-0000-0000000000";
let tokenApi = "e00000000000000000000000000.000000000000000000000000000000000000000000000000000000000000000000.000000000-00000000000-0000000_0";

let sistemaOrigenId = "00000000000000000000";


exports default {
  variables: {
    tokenApi,
    token,
    sistemaOrigenId
  }
}