using Newtonsoft.Json.Linq;
using System;
using System.Threading.Tasks;
namespace AK.Wwise.Waapi
{
class Program
{
static void Main(string[] args)
{
_Main().Wait();
}
static async Task _Main()
{
try
{
await client.Connect();
client.Disconnected += () =>
{
System.Console.WriteLine("We lost connection!");
};
JObject info = await client.Call(ak.wwise.core.getInfo, null, null);
System.Console.WriteLine(info);
var testObj = await client.Call(
ak.wwise.core.@object.create,
new
{
name = "WaapiObject",
parent = @"\Actor-Mixer Hierarchy\Default Work Unit",
type = "ActorMixer",
onNameConflict = "rename"
}, null);
System.Console.WriteLine(testObj["id"]);
int nameSubscriptionId = await client.Subscribe(
ak.wwise.core.@object.nameChanged,
null,
(JObject publication) =>
{
System.Console.WriteLine($"Name changed: {publication}");
});
int propertySubscriptionId = await client.Subscribe(
ak.wwise.core.@object.propertyChanged,
new JObject(
new JProperty("property", "Volume"),
new JProperty("object", testObj["id"])),
(JObject publication) =>
{
System.Console.WriteLine($"Property '{publication["property"]}' changed: {publication["new"]}");
});
try
{
await client.Call(
ak.wwise.core.@object.setName,
new
{
@object = testObj["id"],
value = "NewName"
}, null);
await client.Call(
ak.wwise.ui.commands.execute,
new JObject(new JProperty("command", "Undo")), null);
}
catch (
AK.
Wwise.Waapi.Wamp.ErrorException e)
{
System.Console.Write(e.Message);
}
await client.Call(
ak.wwise.core.@object.setProperty,
new
{
@property = "Volume",
@object = testObj["id"],
value = 6
}, null);
{
dynamic args = new JObject();
args.property = "Volume";
args.@object = testObj["id"];
args.value = 9;
await client.Call(ak.wwise.core.@object.setProperty, args, null);
}
await client.Call(ak.wwise.core.@object.setProperty,
new JObject(
new JProperty("property", "Volume"),
new JProperty("object", testObj["id"]),
new JProperty("value", 10)),
null);
{
var query = new JObject(
new JProperty("from", new JObject(
new JProperty("id", new JArray(new string[] { testObj["id"].ToString() })))));
var options = new JObject(
new JProperty("return", new string[] { "name", "id", "@Volume" }));
JObject result = await client.Call(ak.wwise.core.@object.get, query, options);
System.Console.WriteLine(result["return"][0]["@Volume"]);
}
{
var query = new
{
from = new
{
id = new string[] { testObj["id"].ToString() }
}
};
var options = new
{
@return = new string[] { "name", "id", "@Volume", "path" }
};
JObject jresult = await client.Call(ak.wwise.core.@object.get, query, options);
System.Console.WriteLine(jresult["return"][0]["@Volume"]);
}
await client.Call(
ak.wwise.core.@object.delete,
new JObject(new JProperty("object", testObj["id"])), null);
await client.Unsubscribe(nameSubscriptionId);
await client.Unsubscribe(propertySubscriptionId);
await client.Close();
System.Console.WriteLine("done");
}
catch (Exception e)
{
System.Console.Error.WriteLine(e.Message);
}
}
}
}