def connect(self, frame, response=None):
self.engine.log.debug("<STR_LIT>")<EOL>if self.engine.authenticator:<EOL><INDENT>login = frame.headers.get('<STR_LIT>')<EOL>passcode = frame.headers.get('<STR_LIT>')<EOL>if not self.engine.authenticator.authenticate(login, passcode):<EOL><INDENT>raise AuthError("<STR_LIT>" % login)<EOL><DEDENT><DEDENT>self.engine.connected = True<EOL>response = response or Frame(frames.CONNECTED)<EOL>response.headers['<STR_LIT>'] = uuid.uuid4()<EOL>self.engine.connection.send_frame(response)<EOL>
Handle CONNECT command: Establishes a new connection and checks auth (if applicable).