Matches.NET is a free, open-source (Ms-PL) wrapper for the Campfire API, written in C# and runs on the .NET Framework 4.0.
This library was developed for a product we are working on (FlameCage); seeing the lack of good wrappers for Campfire, we decided to give back to the community and make the library freely available. As this is the core of a commercial product, it is being actively maintained and updated as 37signals updates their Campfire service and API.
❧
Sample
static void Main(string[] args)
{
var site = new Site("site_name",
new NetworkCredential("37signals_username", "37signals_password"));
// get the users API token in order to avoid saving their password
var apiToken = site.GetApiToken();
site.ApiToken = apiToken;
site.Credentials = new NetworkCredential(apiToken, "X");
//Find the General chat room and join
var room = site.GetRooms().Where(r => r.Name == "General").FirstOrDefault();
room.Join();
//Streaming context monitors the room for new messages from other users outputs to console
var streamingContext = room.GetStreamingContext(m => Console.WriteLine("{0}:{1}", m.User.Name, m.Body));
var startStream = new Task(streamingContext.BeginStreaming);
startStream.Start();
room.PlaySound(CampfireSound.Trombone);
room.Say("Hello, World!");
room.UploadFile(File.Open(@"C:\path\to\file", FileMode.Open), "file_name");
while (true)
{
var message = Console.ReadLine();
if (message == "/leave")
{
room.Leave();
break;
}
room.Say(message);
}
var closeStream = new Task(streamingContext.EndStreaming);
closeStream.Start();
closeStream.Wait();
}
❧
Download
The recommended way to download Matches.NET is via NuGet (more info), though for those that would prefer a more traditional package, it can be found on the project’s bitbucket.org download page.
❧
Source Code
The source code can be found on bitbucket.org; feel free to poke around, and send us any ideas or changes you would like to see.
❧
Help & Feedback
Have questions or need some help? Maybe have an idea for a new feature or a better way to do something? Head over to the forums or submit a new issue ticket.
