Exemple #1
0
 def _onConnInput( self, conn, line ) :
     words = line.split()
     if len(words) == 0 : return
     cmd = words[0].lower()
     if cmd == 'msg' :
         if len(words) != 2 : return
         try :
             msg = wordDecode( words[1] )
         except WordDecodeError :
             return
         if self.isHidden() : self.show()
         self._chatMessage( msg, self.peerName )
         self.lastReceivedTyping = False
         self._updateTypingStatus()
     elif cmd == 'typing' :
         if len(words) != 1 : return
         self.lastReceivedTyping = True
         self.lastReceivedTypingTime = time.time()
         self._updateTypingStatus()
Exemple #2
0
 def _onConnInput(self, conn, line):
     words = line.split()
     if len(words) == 0: return
     cmd = words[0].lower()
     if cmd == 'msg':
         if len(words) != 2: return
         try:
             msg = wordDecode(words[1])
         except WordDecodeError:
             return
         if self.isHidden(): self.show()
         self._chatMessage(msg, self.peerName)
         self.lastReceivedTyping = False
         self._updateTypingStatus()
     elif cmd == 'typing':
         if len(words) != 1: return
         self.lastReceivedTyping = True
         self.lastReceivedTypingTime = time.time()
         self._updateTypingStatus()
Exemple #3
0
 def _onInput( self, line ) :
     assert self.state in (self.DEFAULT,self.CONNECTING,self.LISTENER)
     if self.state in (self.CONNECTING,self.LISTENER) :
         self._writeError( 'Junk received' )
         self.shutdown( deferred=True )
         return
     words = line.strip().split()
     if len(words) == 0 : return
     try :
         words = [wordDecode(w) for w in words]
     except WordDecodeError :
         self._writeError( 'Malformed request' )
         return
     cmd = words[0].lower()
     handler = self.requestTable.get( cmd, None )
     if not handler :
         self._writeError( 'Unknown request' )
         return
     handler( words[1:] )