Git Product home page Git Product logo

network-informations's Introduction

network-informations

NPM package version Build Status Minified size Minified+Gzip size License: MIT

Get the client network informations cross-plataform, included network type, local ip address, port number and more

Instalation

This lib is available as a NPM package. To install it, use the following command:

npm install @thadeu/network-informations --save

If you're using Yarn (and you should):

yarn add @thadeu/network-informations

If you dont use ES6/7/8/x, use unpkg file

https://unpkg.com/@thadeu/network-informations/dist/network-informations.min.js

Usage

<script src="https://unpkg.com/@thadeu/network-informations/dist/network-informations.min.js"></script>
var network = networkInformations

network.withConnectionStats(function(stats) {
  var infos = network.localCandidateAttributes(stats.result())
  console.log(infos)
})

results

{
  "candidateType": "host",
  "ipAddress": IP_NUMER,
  "networkType": "wlan",
  "portNumber": "9",
  "priority": "1518280447",
  "stunKeepaliveRequestsSent": "0",
  "stunKeepaliveResponsesReceived": "0",
  "stunKeepaliveRttSquaredTotal": "0",
  "stunKeepaliveRttTotal": "0",
  "transport": "tcp"
}

Usage with ES6+ feature import

localCandidateAttributes

import { withConnectionStats, localCandidateAttributes } from '@thadeu/network-informations'

withConnectionStats(stats => {
  let attributes = localCandidateAttributes(stats.result())
  console.log(attributes)
})

it results something as

{
  "candidateType": "host",
  "ipAddress": IP_NUMER,
  "networkType": "wlan",
  "portNumber": "9",
  "priority": "1518280447",
  "stunKeepaliveRequestsSent": "0",
  "stunKeepaliveResponsesReceived": "0",
  "stunKeepaliveRttSquaredTotal": "0",
  "stunKeepaliveRttTotal": "0",
  "transport": "tcp"
}

allAttributes

import { withConnectionStats, allAttributes } from '@thadeu/network-informations'

withConnectionStats(stats => {
  let attributes = allAttributes(stats.result())
  console.log(attributes)
})

it results something as

{
  "candidateType": "host",
  "googActualEncBitrate": "0",
  "googAvailableReceiveBandwidth": "0",
  "googAvailableSendBandwidth": "0",
  "googBucketDelay": "0",
  "googComponent": "1",
  "googDerBase64": "",
  "googFingerprint": "",
  "googFingerprintAlgorithm": "sha-256",
  "googInitiator": "true",
  "googRetransmitBitrate": "0",
  "googTargetEncBitrate": "0",
  "googTransmitBitrate": "0",
  "ipAddress": "192.168.1.3",
  "label": "webrtchacks",
  "localCertificateId": "",
  "networkType": "wlan",
  "portNumber": "9",
  "priority": "1518280447",
  "protocol": "",
  "state": "connecting",
  "stunKeepaliveRequestsSent": "0",
  "stunKeepaliveResponsesReceived": "0",
  "stunKeepaliveRttSquaredTotal": "0",
  "stunKeepaliveRttTotal": "0",
  "transport": "tcp"
}

If you have an connection legacy, should be use

import { withConnectionStats, localCandidateAttributes } from '@thadeu/network-informations'

withConnectionStats(stats => {
  let attributes = localCandidateAttributes(stats.result())
  console.log(attributes)
}, myPeerConnectionLegacy)

Do you developer?

watching tests

npm run test:watch

We going to enjoy!!

Contributing

Once you've made your great commits (include tests, please):

  1. Fork this repository
  2. Create a topic branch - git checkout -b my_branch
  3. Push to your branch - git push origin my_branch
  4. Create a pull request

That's it!

Please respect the indentation rules and code style. And use 2 spaces, not tabs. And don't touch the version thing or distribution files; this will be made when a new version is going to be released.

License

(The MIT License)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

network-informations's People

Contributors

thadeu avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.