Skip to content

Instantly share code, notes, and snippets.

@haraldfianbakken
Created March 8, 2013 08:58
Show Gist options
  • Save haraldfianbakken/5115132 to your computer and use it in GitHub Desktop.
Save haraldfianbakken/5115132 to your computer and use it in GitHub Desktop.
Buddy commands - REST API
using System;
using System.Web.Mvc;
using ibuddylib;
namespace SharePirates.BuddyWeb.Controllers
{
public class BuddyController : Controller, IBuddyCommands
{
private static BuddyAnimator _animator;
public BuddyController()
{
if (_animator == null)
{
_animator = new BuddyAnimator(BuddyManager.Global.AnyBuddy);
}
}
public ActionResult Index()
{
return View();
}
public ActionResult Flash(string color)
{
_animator.FlashColor((HeadColor) Enum.Parse(typeof(HeadColor), color, true));
return new EmptyResult();
}
public ActionResult Twist()
{
_animator.Twist();
return new EmptyResult();
}
public ActionResult HeartBeat(int ms=-1)
{
if (ms > 0)
{
_animator.HeartBeat(ms);
}
else
{
_animator.HeartBeat();
}
return new EmptyResult();
}
public ActionResult HeadColor(string color)
{
_animator.Buddy.HeadColor = ((HeadColor) Enum.Parse(typeof(HeadColor), color, true));
return new EmptyResult();
}
public ActionResult InvertHeart()
{
_animator.InvertHeart();
return new EmptyResult();
}
public ActionResult HeartColor(string color)
{
_animator.Buddy.HeartLight = ((HeartLight)Enum.Parse(typeof(HeartLight), color, true));
return new EmptyResult();
}
public ActionResult Wag()
{
_animator.Wag();
return new EmptyResult();
}
public ActionResult Flap()
{
_animator.Flap();
return new EmptyResult();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment