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

ngxi4-socket-client

v0.0.9

Published

This library was generated by Doan Quoc Cuong ([email protected])

Downloads

2

Readme

Ngxi4SocketClient

This library was generated by Doan Quoc Cuong ([email protected])

Install:

Run npm to get service for using.


npm install ngxi4-socket-client --save

Run npm to install include extra javascript.

npm install ngx-device-detector ngx-socket-io --save

npm install ngxi4-dynamic-service --save

# And install all extra of ngxi4-dynamic-service (search for help of this library)
npm install croppie crypto-js exif-js simple-crypto-js --save

npm install [email protected] ngx-image-cropper [email protected] [email protected] --save

# version "ng-multiselect-dropdown": "^0.2.10" 
# npm i ng-multiselect-dropdown@latest
npm install @ionic/[email protected] [email protected]

npm install @ionic-native/sqlite  --save

# version của angular for event 
# error import { EventHandler } from '@ionic/angular/dist/providers/events'

# npm install angular-webstorage-service@latest
# Error: angular-webstorage-service/src/storage-service.module.d.ts:9:22 - error NG6002: Appears in the NgModule.imports of
# npm un angular-webstorage-service --save
npm i ngx-webstorage-service --save 

npm install ngx-qrcode2@latest

Download JsEncrypt and copy in assets/js/jsencrypt.js


http://travistidwell.com/jsencrypt/

<!-- Save in src/assets/js/jsencrypt.js -->

Add javascript jsencrypt.js in angular.json

{

"projects": {
    "app": {
      // ...
      "architect": {
        "build": {
          // ...
            "scripts": [
              "src/assets/js/jsencrypt.js"
            //   ,"src/assets/js/communicate2Angular.js"
            ]
          // ...
        },
        // ...
      }
    }
  },
  //   ...
}

Use:

1. add in ./app.module.ts

import { Ngxi4SocketClientModule } from 'ngxi4-socket-client'

@NgModule({
  // ...
  imports: [
    // ....
    // add module ngxi4-socket-client
    Ngxi4SocketClientModule.forRoot()

    // or 
    // Ngxi4SocketClientModule.forRoot(
        //  {
        //     APP_NAME: "YOUR-APP-NAME"
        //     , SERVER_URL: "your socket-server"
        //     , SOCKET_PATH: "your socket-path"
        //     , PING_INTERVAL: 1000
        //     , TIME_OUT: 60000
        //     , RECONNECT_DELAY: undefined
        //     , RECONNECT_DELAY_MAX: undefined
        // }
    )

  ]
})

2. add to ./app.component.ts

import { Component } from '@angular/core';

import { Platform } from '@ionic/angular';
import { SplashScreen } from '@ionic-native/splash-screen/ngx';
import { StatusBar } from '@ionic-native/status-bar/ngx';
import { ApiSocketService } from './services/api-socket.service';


@Component({
  selector: 'app-root',
  templateUrl: 'app.component.html',
  styleUrls: ['app.component.scss']
})
export class AppComponent {
  constructor(
    private platform: Platform,
    private splashScreen: SplashScreen,
    private statusBar: StatusBar,
    private apiSocket: ApiSocketService
  ) {
    this.initializeApp();
  }

  initializeApp() {
    this.platform.ready().then(() => {
      this.statusBar.styleDefault();
      this.splashScreen.hide();
      this.init();
    });
  }
  init() {
    this.apiSocket.init()    
    // or
    // this.apiSocket.init(
    // server_url?: string
    // , socket_path?: string
    // , ping_interval?: number
    // , time_out?: number
    // , reconnect_delay?: number
    // , reconnect_delay_max?: number
    // , appName?: any     // tên ứng dụng nếu có
    // , extraEvents?: any // sự kiện thêm vào không phải mặc định
    // , callback?: any   
    // )
    // NOTE: if input by this param --> the config in module (1.) is replaced
  }
}

3. add to ./my-home.page.ts


import { Component, HostListener } from '@angular/core';
import { CommonsService } from 'ngxi4-dynamic-service';
import { ApiSocketService } from '../services/api-socket.service';

@Component({
  selector: 'app-home',
  templateUrl: 'home.page.html',
  styleUrls: ['home.page.scss'],
})
export class HomePage {

  isMobile: boolean = false;
  socketConnection: any;

  @HostListener('window:resize', ['$event'])
  onResize(event) {
    this.isMobile = event.target.innerWidth < 576;
  }

  constructor(
    private apiCommon: CommonsService
    , private apiSocket: ApiSocketService
  ) { this.init() }

  init() {
    this.isMobile = this.apiCommon.isMobile()
    this.socketConnection = this.apiSocket.getConnection();
  }

  onClickUser() {
    if (this.socketConnection.userInfo) {
      // hiển thị thông tin của userInfo đã kết nối vào
      // view form chứa user info này
      // console.log('Thông tin user', this.socketConnection.userInfo);
      // gửi lệnh lên server kiểm tra có bao nhiêu socket đang nối với user này
      // ở những máy tính nào
      this.apiSocket.sendSocketIo("client-req-command", { command: "GET-MY-USER" })
    } else {
      this.apiSocket.sendSocketIo("client-req-command", { command: "LOGIN" })
    }
  }

  onClickDevice() {
    if (this.socketConnection.device_online) {
      // hiển thị thông tin của userInfo đã kết nối vào
      // view form chứa user info này
      // console.log('Thông tin thiết bị', this.socketConnection.device_id);
      // gửi thông tin lên máy chủ, xem có bao nhiêu socket đang dùng bộ key với device_id này
      // máy chủ trả về form thông tin thiết bị đang nối ở những device nào
      this.apiSocket.sendSocketIo("client-req-command", { command: "GET-MY-DEVICE" })
    }
  }
}