forked from sidorares/node-mysql2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
35 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
"client_handshake server_handshake query execute".split(' ').forEach(function(name) { | ||
"client_handshake server_handshake query execute ping".split(' ').forEach(function(name) { | ||
var ctor = require('./' + name); | ||
module.exports[ctor.name] = ctor; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
var Command = require('./command'); | ||
var util = require('util'); | ||
var CommandCode = require('../constants/commands'); | ||
var Packet = require('../packets/packet'); | ||
|
||
// TODO: time statistics? | ||
// usefull for queue size and network latency monitoring | ||
// store created,sent,reply timestamps | ||
|
||
function Ping(callback) | ||
{ | ||
Command.call(this); | ||
this.onResult = callback; | ||
} | ||
util.inherits(Ping, Command); | ||
|
||
Ping.prototype.start = function(packet, connection) { | ||
var ping = new Packet(0, new Buffer([0, 0, 0, 0, CommandCode.PING])); | ||
connection.writePacket(ping); | ||
return Ping.prototype.pingResponse; | ||
}; | ||
|
||
Ping.prototype.pingResponse = function(packet) { | ||
// TODO: check it's OK packet. error check already done in caller | ||
if (this.onResult) | ||
this.onResult(); | ||
return null; | ||
}; | ||
|
||
module.exports = Ping; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters