Skip to content
Jason Dentler edited this page Jul 20, 2011 · 3 revisions

HermesClient

HermesClient(serviceUrl) - The constructor for the Hermes service takes as a parameter the url to the Hermes REST service.

	var client = new HermesClient('http://server.domain.com/Hermes');

GetGroups() returns a standard jQuery promise for an array of Groups.

	client.GetGroups()
	.done(function (groups) {
		for(var i = 0; i < groups.length; i++)
			console.log(groups[i].Name);
	})
	.fail(function (xhr, status, ex) {
			console.log('Failed to get Hermes groups');
	});

CreateGroup(name, description) sends a request to create a new Hermes group and returns a Group Proxy for the newly created group.

	client.CreateGroup('Chat Server')
	.done(function (group) {
		console.log(group.Name + ' group created.');
	})
	.fail(function (xhr, status, ex) {
		console.log('Failed to create Hermes group');
	});

GetGroupByName(name) returns a Group Proxy for an existing group. When resolved, the promise may return null if the group does not exist.

client.GetGroupByName('Chat Server')
	.done(function (group) {
		if (group != null) {
			console.log('Got the ' + group.Name + ' group.');
			return;
		};
		console.log('The Chat Server group does not exist.');
	})
	.fail(function (xhr, status, ex) {
		console.log('Failed to get the group');
	});

GetGroup(id) returns a Group Proxy. Requests a group by id.

	client.GetGroup(groupId)
	.done(function (group) {
		console.log('Got the ' + group.Name + ' group.');
	})
	.fail(function (xhr, status, ex) {
		console.log('Failed to get the group');
	});

TryCreateGroup(name, description) returns a Group Proxy. If a group with the name exists, it is returned. Otherwise, a new group is created. The description parameter is only used when creating a new group. An existing group with a matching name may have a different description.

	var topicProxy = client.TryCreateGroup('Chat Server', 'Contains chat topics')
		.TryCreateTopic('Weather', 'Chat about the weather');