示例#1
0
    /// <summary>
    /// Send a WAAPI call to create a transport in Wwise.
    /// Subscribe to the ak.wwise.core.transport.stateChanged topic of the new transport.
    /// Add the transport info to ItemTransports.
    /// </summary>
    /// <param name="guid">GUID of the Event</param>
    /// <returns></returns>
    static async private Task <TransportInfo> CreateTransport(System.Guid guid)
    {
        var args   = new ArgsObject(guid.ToString("B"));
        var result = await WaapiClient.Call(ak.wwise.core.transport.create, args, null, timeout : 1000);

        int  transportID    = UnityEngine.JsonUtility.FromJson <ReturnTransport>(result).transport;
        var  options        = new TransportOptions(transportID);
        uint subscriptionID = await WaapiClient.Subscribe(ak.wwise.core.transport.stateChanged, options, HandleTransportStateChanged);

        var transport = new TransportInfo(transportID, subscriptionID);

        ItemTransports.Add(guid, transport);
        return(transport);
    }
示例#2
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));
        }
    }