Skip to content

kelumKP/SharpTox

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SharpTox Build Status

This project aims to provide a simple library that wraps all of the functions found in the Tox library. Tox is a free (as in freedom) Skype replacement.

Feel free to contribute!

Things you'll need

  • The libtox(core, av and dns) library, you should compile that yourself from the ProjectTox GitHub repo. Guidelines on how to do this can be found here. If you don't feel like compiling this yourself, you can find automatic builds for windows here: x86 or x64

  • Depending on how you compiled the core libraries, the names of those may differ from the defaults in SharpTox. Be sure to change the value of the const string dll in ToxFunctions.cs, ToxAvFunctions.cs, ToxDnsFunctions.cs and ToxEncryptionFunctions.cs accordingly if needed.

Looking for precompiled binaries? Check this.

SharpTox should also work on Unix-like systems (mostly untested). Select the POSIX build configs if you're interested in that.

Basic Usage

using System;
using SharpTox.Core;

class Program
{
    static Tox tox;

    static void Main(string[] args)
    {
        ToxOptions options = new ToxOptions(true, false);

        tox = new Tox(options);
        tox.OnFriendRequest += tox_OnFriendRequest;
        tox.OnFriendMessage += tox_OnFriendMessage;

        foreach (ToxNode node in Nodes)
            tox.BootstrapFromNode(node);

        tox.Name = "SharpTox";
        tox.StatusMessage = "Testing SharpTox";

        tox.Start();

        string id = tox.Id.ToString();
        Console.WriteLine("ID: {0}", id);

        Console.ReadKey();
        tox.Dispose();
    }

    //check https://wiki.tox.im/Nodes for an up-to-date list of nodes
    static ToxNode[] Nodes = new ToxNode[]
    {
        new ToxNode("192.254.75.98", 33445, new ToxKey(ToxKeyType.Public, "951C88B7E75C867418ACDB5D273821372BB5BD652740BCDF623A4FA293E75D2F")),
        new ToxNode("144.76.60.215", 33445, new ToxKey(ToxKeyType.Public, "04119E835DF3E78BACF0F84235B300546AF8B936F035185E2A8E9E0A67C8924F"))
    };

    static void tox_OnFriendMessage(object sender, ToxEventArgs.FriendMessageEventArgs e)
    {
        //get the name associated with the friendnumber
        string name = tox.GetName(e.FriendNumber);

        //print the message to the console
        Console.WriteLine("<{0}> {1}", name, e.Message);
    }

    static void tox_OnFriendRequest(object sender, ToxEventArgs.FriendRequestEventArgs e)
    {
        //automatically accept every friend request we receive
        tox.AddFriendNoRequest(new ToxKey(ToxKeyType.Public, e.Id));
    }
}

Toxy

If you're considering using SharpTox for your project, you should definitely have a look at Toxy. Toxy is a metro-style Tox client for windows. It has most of the functionality of Tox implemented.

Toxy is available here.

Contact

  • Join the official IRC channel #tox-dev on freenode Official Tox Dev IRC Channel

About

Wrapper library for Tox core, av and dns functions

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%