def encode(nickname, message):
    """Encodes a message as a comma separated list to be sent to the chat server"""

    # Construct the payload
    payload = '%s,%s' % (nickname, message)

    # Encode the payload as utf-8 byte stream, so it can be sent to the chat server
    return str.encode(payload, 'utf-8')