code: def server_extensions_handshake(requested, supported):
      accepts = {}
      for offer in requested:
          name = offer.split(";", 1)[0].strip()
          for extension in supported:
              if extension.name == name:
                  accept = extension.accept(offer)
                  if accept is True:
                      accepts[extension.name] = True
                  elif accept is not False and accept is not None:
                      accepts[extension.name] = accept.encode("ascii")
      if accepts:
          extensions = []
          for name, params in accepts.items():
              if params is True:
                  extensions.append(name.encode("ascii"))
              else:
                  params = params.decode("ascii")
                  if params == "":
                      extensions.append(("%s" % (name)).encode("ascii"))
                  else:
                      extensions.append(("%s; %s" % (name, params)).encode("ascii"))
          return b", ".join(extensions)
      return None