Giter Site home page Giter Site logo

Server ping about node-samp-query HOT 6 OPEN

jjj4n avatar jjj4n commented on August 16, 2024 1
Server ping

from node-samp-query.

Comments (6)

PixellUp avatar PixellUp commented on August 16, 2024

@JJJ4n It would be awesome if you could have it. We could send to 'p' channel for pseudo-ping response http://wiki.sa-mp.com/wiki/Query

from node-samp-query.

DimaCrafter avatar DimaCrafter commented on August 16, 2024

For first we define timer variable before try at line 72-73:

socket.send(packet, 0, packet.length, options.port, options.host, function(error, bytes) {
For example let ping_start.

After line 74

if(error) return callback.apply(options, [ error ])
we saving current timestamp to timer variable.
ping_start = Date.now()

After receiving message from server we "stopping" timer after line 89

socket.on('message', function (message) {

let ping = Date.now() - ping_start; and passing result at line 100
var object = {}
var object = {ping}.

Don't forget return it in query result near line 29

response.online = information.players
response.ping = information.ping

from node-samp-query.

PixellUp avatar PixellUp commented on August 16, 2024

@DimaCrafter It would be awesome if you could PR those changes 👍

from node-samp-query.

DimaCrafter avatar DimaCrafter commented on August 16, 2024

@PixellUp how I can do it?I don`t understand how contribute projects on github.

from node-samp-query.

PixellUp avatar PixellUp commented on August 16, 2024

@DimaCrafter There are plenty of tutorials how you could do it, in fact, it's very simple. Check those links below.

https://www.youtube.com/watch?v=yr6IzOGoMsQ
https://gist.github.com/MarcDiethelm/7303312

from node-samp-query.

DimaCrafter avatar DimaCrafter commented on August 16, 2024

My fork with ping estimation: https://github.com/DimaCrafter/node-samp-query

from node-samp-query.

Related Issues (6)

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.