From 00061ce2c4f0024fff43414908f8f1230fadc54c Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Sebasti=C3=A1n=20Santisi?= <s@ntisi.com.ar>
Date: Tue, 10 May 2011 16:32:05 -0300
Subject: [PATCH 5/9] Implement client-side PNG/QNG

Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
---
 msncb.py  |    5 +++++
 msnlib.py |    6 ++++++
 2 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/msncb.py b/msncb.py
index 7f8b016..c2b73bd 100644
--- a/msncb.py
+++ b/msncb.py
@@ -76,6 +76,7 @@ class cb:
 		self.ack = cb_ack	# message acknowledge
 		self.nak = cb_nak	# message negative acknowledge
 		self.bye = cb_bye	# switchboard user disconnect
+		self.qng = cb_qng	# pong!
 
 
 
@@ -531,3 +532,7 @@ def cb_bye(md, type, tid, params, sbd):
 		debug('BYE: closing %s' % str(sbd))
 		md.close(sbd)
 
+def cb_qng(md, type, tid, params):
+	"Get the response of a ping"
+	debug('PONG!: answered by the server')
+
diff --git a/msnlib.py b/msnlib.py
index 6e87856..cf1dce0 100644
--- a/msnlib.py
+++ b/msnlib.py
@@ -455,6 +455,10 @@ class msnd:
 			pass
 		del(sb)
 
+	def ping(self):
+		"Sends a ping to the server"
+		try: self.fd.send('PNG\r\n')
+		except: pass
 
 	def invite(self, email, sbd):
 		"Invites a user into an existing sbd"
@@ -679,6 +683,8 @@ class msnd:
 		elif type == 'NAK': self.cb.nak(self, type, tid, params, nd)
 		elif type == 'BYE': self.cb.bye(self, type, tid, params, nd)
 
+		elif type == 'QNG': self.cb.qng(self, type, tid, params)
+
 		elif type == 'MSG':
 			params = tid + ' ' + params
 			mlen = int(r[2].split()[-1])
-- 
1.6.2.2.646.gb214

