git » msnlib » commit 00061ce

Implement client-side PNG/QNG

author Sebastián Santisi
2011-05-10 19:32:05 UTC
committer Alberto Bertogli
2011-05-10 19:34:29 UTC
parent 9d464d5e542af7609e6ca97beed1d5ce167bbddf

Implement client-side PNG/QNG

Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>

msncb.py +5 -0
msnlib.py +6 -0

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])