Example #1
0
    /// <summary>
    /// Handle the messages published by a transport when its state is changed.
    /// If stopped, enqueue a command with DestroyTransport as its payload.
    /// </summary>
    /// <param name="message"></param>
    static private void HandleTransportStateChanged(string message)
    {
        TransportState transport = UnityEngine.JsonUtility.FromJson <TransportState>(message);

        System.Guid itemID      = new System.Guid(transport.@object);
        int         transportID = transport.transport;

        if (transport.state == WaapiKeywords.STOPPED)
        {
            waapiCommandQueue.Enqueue(new WaapiCommand(
                                          async() => await DestroyTransport(itemID)));
        }

        else if (transport.state == WaapiKeywords.PLAYING && !ItemTransports.ContainsKey(itemID))
        {
            ItemTransports.Add(itemID, new TransportInfo(transportID, 0));
        }
    }
Example #2
0
    /// <summary>
    /// Unsubscribe from the transport topic and send a WAAPI command to destroy the transport in Wwise.
    /// </summary>
    /// <param name="in_itemID"> GUID of the Event.</param>
    /// <returns></returns>
    static async Task <string> DestroyTransport(System.Guid in_itemID)
    {
        if (!ItemTransports.ContainsKey(in_itemID))
        {
            return(null);
        }

        if (ItemTransports[in_itemID].SubscriptionID != 0)
        {
            await WaapiClient.Unsubscribe(ItemTransports[in_itemID].SubscriptionID);
        }

        var args   = new ArgsTransport(ItemTransports[in_itemID].TransportID);
        var result = await WaapiClient.Call(ak.wwise.core.transport.destroy, args, null);

        ItemTransports.Remove(in_itemID);
        return(result);
    }