def on_read(self, result, error): if error: self.disconnect(error=error[1]) elif not result: self.disconnect(error="Connection closed by remote host") else: self.source = source = ui.Source() self.buffer = (self.buffer + result).split("\r\n") for line in self.buffer[:-1]: self.got_msg(line) if self.buffer: self.buffer = self.buffer[-1] else: self.buffer = '' if source.enabled: self.source = ui.fork(self.on_read, self.socket.recv, 8192)
def on_connect(self, result, error): if error: self.disconnect(error=error[1]) #we should immediately retry if we failed to open the socket and there are hosts left if self.status == DISCONNECTED and not self.failedlasthost: windows.get_default(self, self.core.manager).write( "* Retrying with next available host") self.connect() else: self.source = source = ui.Source() self.status = INITIALIZING self.failedhosts[:] = () self.events.trigger('SocketConnect', network=self) if source.enabled: self.source = ui.fork(self.on_read, self.socket.recv, 8192) # Auto join channels on connect for channel in self.core.channels: self.core.run_command("/join %s" % channel)