Skip to content

Channel Viewer Protocol (CVP)

HarpyWar edited this page May 29, 2017 · 1 revision

Warning! .NET Ice method GetTree() does not work with Murmur 1.2.9 and earlier https://github.com/mumble-voip/mumble/issues/1874

For Murmur 1.3.0+ you can use var tree = server.GetTree() and then iterate over all tree.

For earlier versions you have to use methods GetOnlineUsers() and GetChannels() instead.

PrintTree(); // print all channels and users to console
private static void PrintTree(IVirtualServer server)
{
	if (!server.IsRunning())
	{
		Console.WriteLine("Server is not running!");
		return;
	}
	displayChannels(s);
}

private static void displayChannels(IVirtualServer s)
{
	var channels = s.GetAllChannels().OrderBy(c => c.Value.Name).OrderBy(c => c.Value.Position).ToList();
	var users = s.GetOnlineUsers().OrderBy(c => c.Value.Name).ToList();
	nextChannels(channels, users, -1);
}

private static void nextChannels(List<KeyValuePair<int, VirtualServerEntity.Channel>> channels, List<KeyValuePair<int, VirtualServerEntity.OnlineUser>> users, int parentId)
{
	var children = channels.Where(c => c.Value.ParentId == parentId).ToList();
	foreach (var c in children)
	{
		Console.WriteLine("{0} > {1}", c.Value.ParentId, c.Value.Name);
		foreach (var u in users.Where(u => u.Value.ChannelId == c.Value.Id))
		{
			Console.WriteLine("* {0}", u.Value.Name);
		}
		nextChannels(channels, users, c.Value.Id);
	}
}
Clone this wiki locally