Test connection by pinging server if no recent pings from server
This commit is contained in:
parent
c45f7ea070
commit
d1920d2cca
3 changed files with 28 additions and 0 deletions
|
@ -48,6 +48,7 @@ CHANGELOG
|
|||
* Third beep sound for when your initials are mentioned in memos - Kiooeht [evacipatedBox] (Idea: Lexi [lexicalNuance])
|
||||
* Ctrl + click to copy links - Kiooeht [evacipatedBox]
|
||||
* Say something when server is full - Kiooeht [evacipatedBox]
|
||||
* Ping server if no ping from server to test connection - Kiooeht [evacipatedBox] (Idea: Lexi [lexicalNuance])
|
||||
* Bug fixes
|
||||
* Logviewer updates - Kiooeht [evacipatedBox]
|
||||
* Memo scrollbar thing - Kiooeht [evacipatedBox]
|
||||
|
|
12
irc.py
12
irc.py
|
@ -5,6 +5,7 @@ from oyoyo import helpers
|
|||
import logging
|
||||
import random
|
||||
import socket
|
||||
from time import time
|
||||
|
||||
from dataobjs import Mood, PesterProfile
|
||||
from generic import PesterList
|
||||
|
@ -266,6 +267,13 @@ class PesterIRC(QtCore.QThread):
|
|||
except socket.error:
|
||||
self.setConnectionBroken()
|
||||
|
||||
@QtCore.pyqtSlot()
|
||||
def pingServer(self):
|
||||
try:
|
||||
self.cli.send("PING %s" % int(time()))
|
||||
except socket.error:
|
||||
self.setConnectionBroken()
|
||||
|
||||
moodUpdated = QtCore.pyqtSignal(QtCore.QString, Mood)
|
||||
colorUpdated = QtCore.pyqtSignal(QtCore.QString, QtGui.QColor)
|
||||
messageReceived = QtCore.pyqtSignal(QtCore.QString, QtCore.QString)
|
||||
|
@ -471,6 +479,10 @@ class PesterHandler(DefaultCommandHandler):
|
|||
def toomanypeeps(self, *stuff):
|
||||
self.parent.tooManyPeeps.emit()
|
||||
|
||||
def ping(self, prefix, server):
|
||||
self.parent.mainwindow.lastping = int(time())
|
||||
self.client.send('PONG', server)
|
||||
|
||||
def getMood(self, *chums):
|
||||
chumglub = "GETMOOD "
|
||||
for c in chums:
|
||||
|
|
|
@ -1641,6 +1641,12 @@ class PesterWindow(MovingWindow):
|
|||
self.connect(self, QtCore.SIGNAL('pcUpdate(QString, QString)'),
|
||||
self, QtCore.SLOT('updateMsg(QString, QString)'))
|
||||
|
||||
self.pingtimer = QtCore.QTimer()
|
||||
self.connect(self.pingtimer, QtCore.SIGNAL('timeout()'),
|
||||
self, QtCore.SLOT('checkPing()'))
|
||||
self.lastping = int(time())
|
||||
self.pingtimer.start(1000*10)
|
||||
|
||||
@QtCore.pyqtSlot(QtCore.QString, QtCore.QString)
|
||||
def updateMsg(self, ver, url):
|
||||
if not hasattr(self, 'updatemenu'):
|
||||
|
@ -1663,6 +1669,12 @@ class PesterWindow(MovingWindow):
|
|||
def noUpdatePC(self):
|
||||
self.updatemenu = None
|
||||
|
||||
@QtCore.pyqtSlot()
|
||||
def checkPing(self):
|
||||
curtime = int(time())
|
||||
if curtime - self.lastping > 300:
|
||||
self.pingServer.emit()
|
||||
|
||||
def profile(self):
|
||||
return self.userprofile.chat
|
||||
def closeConversations(self, switch=False):
|
||||
|
@ -2880,6 +2892,7 @@ class PesterWindow(MovingWindow):
|
|||
closeSignal = QtCore.pyqtSignal()
|
||||
reconnectIRC = QtCore.pyqtSignal()
|
||||
gainAttention = QtCore.pyqtSignal(QtGui.QWidget)
|
||||
pingServer = QtCore.pyqtSignal()
|
||||
|
||||
class PesterTray(QtGui.QSystemTrayIcon):
|
||||
def __init__(self, icon, mainwindow, parent):
|
||||
|
@ -3038,6 +3051,8 @@ class MainProgram(QtCore.QObject):
|
|||
'channelNames(QString)'),
|
||||
('inviteChum(QString, QString)',
|
||||
'inviteChum(QString, QString)'),
|
||||
('pingServer()',
|
||||
'pingServer()'),
|
||||
('reconnectIRC()', 'reconnectIRC()')
|
||||
]
|
||||
# IRC --> Main window
|
||||
|
|
Loading…
Reference in a new issue