<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def signal(self, session_id, payload, connection_id=None):
 """ Send signals to all participants in an active OpenTok session or to a specific client connected to that session. :param String session_id: The session ID of the OpenTok session that receives the signal :param Dictionary payload: Structure that contains both the type and data fields. These correspond to the type and data parameters passed in the client signal received handlers :param String connection_id: The connection_id parameter is an optional string used to specify the connection ID of a client connected to the session. If you specify this value, the signal is sent to the specified client. Otherwise, the signal is sent to all clients connected to the session """

        response = requests.post(
            self.endpoints.signaling_url(session_id, connection_id),
            data=json.dumps(payload),
            headers=self.json_headers(),
            proxies=self.proxies,
            timeout=self.timeout
        )

        if response.status_code == 204:
            pass
        elif response.status_code == 400:
            raise SignalingError('One of the signal properties - data, type, sessionId or connectionId - is invalid.')
        elif response.status_code == 403:
            raise AuthError('You are not authorized to send the signal. Check your authentication credentials.')
        elif response.status_code == 404:
            raise SignalingError('The client specified by the connectionId property is not connected to the session.')
        elif response.status_code == 413:
            raise SignalingError('The type string exceeds the maximum length (128 bytes), or the data string exceeds the maximum size (8 kB).')
        else:
            raise RequestError('An unexpected error occurred', response.status_code)