// Copyright (c) 2019-2020, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto.  Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once

#include "MessagingTypes.h"

#include <carb/Interface.h>

namespace carb
{
namespace messaging
{
/**
 * Defines a messaging interface.
 */
struct IMessaging
{
    CARB_PLUGIN_INTERFACE("carb::messaging::IMessaging", 0, 3)

    /**
     * Listens to a channel and keep receiving message from it until @ref stopChannel is called.
     * This also creates the channel, if it doesn't already exist.
     *
     * @param desc The description of listen settings.
     * @param onMessage Callback function to be called when a message is received.
     * @param userData Custom user data to be passed back in callback function.
     * @return the channel joined.
     */
    Channel*(CARB_ABI* joinChannel)(const ListenChannelDesc* desc, OnMessageFn onMessage, void* userData);

    /**
     * Stops listening to a channel.
     *
     * @param channel The Channel to stop listening to.
     * @param connectionLost Whether the stop request is due to a connection lose.
     */
    void(CARB_ABI* leaveChannel)(const Channel* channel, bool connectionLost);

    /**
     * Sends a message.
     *
     * @param desc The description of the message.
     * @param onMessage Callback function to be called when a message is sent.
     * @param userData Custom user data to be passed back in callback function.
     */
    void(CARB_ABI* sendMessage)(const SendMessageDesc* desc, OnMessageFn onMessage, void* userData);
};
}
}
