def handshake(self, protocol='<STR_LIT>', width=<NUM_LIT>, height=<NUM_LIT>, dpi=<NUM_LIT>,<EOL>audio=None, video=None, image=None, **kwargs):
if protocol not in PROTOCOLS:<EOL><INDENT>self.logger.debug('<STR_LIT>' % protocol)<EOL>raise GuacamoleError('<STR_LIT>')<EOL><DEDENT>if audio is None:<EOL><INDENT>audio = list()<EOL><DEDENT>if video is None:<EOL><INDENT>video = list()<EOL><DEDENT>if image is None:<EOL><INDENT>image = list()<EOL><DEDENT>self.logger.debug('<STR_LIT>')<EOL>self.send_instruction(Instruction('<STR_LIT>', protocol))<EOL>instruction = self.read_instruction()<EOL>self.logger.debug('<STR_LIT>'<EOL>% str(instruction))<EOL>if not instruction:<EOL><INDENT>self.close()<EOL>raise GuacamoleError(<EOL>'<STR_LIT>')<EOL><DEDENT>if instruction.opcode != '<STR_LIT:args>':<EOL><INDENT>self.close()<EOL>raise GuacamoleError(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' % instruction.opcode)<EOL><DEDENT>self.logger.debug('<STR_LIT>'<EOL>% (width, height, dpi))<EOL>self.send_instruction(Instruction('<STR_LIT:size>', width, height, dpi))<EOL>self.logger.debug('<STR_LIT>' % audio)<EOL>self.send_instruction(Instruction('<STR_LIT>', *audio))<EOL>self.logger.debug('<STR_LIT>' % video)<EOL>self.send_instruction(Instruction('<STR_LIT>', *video))<EOL>self.logger.debug('<STR_LIT>' % image)<EOL>self.send_instruction(Instruction('<STR_LIT:image>', *image))<EOL>connection_args = [<EOL>kwargs.get(arg.replace('<STR_LIT:->', '<STR_LIT:_>'), '<STR_LIT>') for arg in instruction.args<EOL>]<EOL>self.logger.debug('<STR_LIT>' % connection_args)<EOL>self.send_instruction(Instruction('<STR_LIT>', *connection_args))<EOL>instruction = self.read_instruction()<EOL>self.logger.debug('<STR_LIT>'<EOL>% str(instruction))<EOL>if instruction.opcode != '<STR_LIT>':<EOL><INDENT>self.logger.warning(<EOL>'<STR_LIT>')<EOL><DEDENT>if instruction.args:<EOL><INDENT>self._id = instruction.args[<NUM_LIT:0>]<EOL>self.logger.debug(<EOL>'<STR_LIT>' % self.id)<EOL><DEDENT>self.logger.debug('<STR_LIT>')<EOL>self.connected = True<EOL>
Establish connection with Guacamole guacd server via handshake.