/// <summary> /// Initialises a new instance of toxav. /// </summary> /// <param name="tox"></param> /// <param name="maxCalls"></param> public ToxAv(ToxHandle tox, int maxCalls) { _tox = tox; _toxAv = ToxAvFunctions.New(tox, maxCalls); if (_toxAv == null || _toxAv.IsInvalid) throw new Exception("Could not create a new instance of toxav."); MaxCalls = maxCalls; }
/// <summary> /// Initializes a new instance of Tox. If no secret key is specified, toxcore will generate a new keypair. /// </summary> /// <param name="options">The options to initialize this instance of Tox with.</param> /// <param name="secretKey">Optionally, specify the secret key to initialize this instance of Tox with. Must be ToxConstants.SecretKeySize bytes in size.</param> public Tox(ToxOptions options, ToxKey secretKey = null) { var error = ToxErrorNew.Ok; var optionsStruct = options.Struct; if (secretKey != null) optionsStruct.SetData(secretKey.GetBytes(), ToxSaveDataType.SecretKey); _tox = ToxFunctions.New(ref optionsStruct, ref error); if (_tox == null || _tox.IsInvalid || error != ToxErrorNew.Ok) throw new Exception("Could not create a new instance of tox, error: " + error.ToString()); optionsStruct.Free(); Options = options; }
internal static extern bool SelfSetName(ToxHandle tox, byte[] name, uint length, ref ToxErrorSetInfo error);
internal static extern bool FriendGetStatusMessage(ToxHandle tox, uint friendNumber, byte[] message, ref ToxErrorFriendQuery error);
internal static extern int GroupSetTitle(ToxHandle tox, int groupnumber, byte[] title, byte length);
internal static extern uint FriendByPublicKey(ToxHandle tox, byte[] publicKey, ref ToxErrorFriendByPublicKey error);
internal static extern ulong FriendGetLastOnline(ToxHandle tox, uint friendNumber, ref ToxErrorFriendGetLastOnline error);
internal static extern int DelGroupchat(ToxHandle tox, int groupnumber);
internal static extern uint FileSend(ToxHandle tox, uint friendNumber, ToxFileKind kind, ulong fileSize, byte[] fileId, byte[] fileName, uint fileNameLength, ref ToxErrorFileSend error);
internal static extern void RegisterTypingChangeCallback(ToxHandle tox, ToxDelegates.CallbackTypingChangeDelegate callback, IntPtr userdata);
internal static extern void RegisterFriendConnectionStatusCallback(ToxHandle tox, ToxDelegates.CallbackFriendConnectionStatusDelegate callback, IntPtr userdata);
internal static extern void RegisterStatusMessageCallback(ToxHandle tox, ToxDelegates.CallbackStatusMessageDelegate callback, IntPtr userdata);
internal static extern void RegisterUserStatusCallback(ToxHandle tox, ToxDelegates.CallbackUserStatusDelegate callback, IntPtr userdata);
internal static extern int GroupPeerPubkey(ToxHandle tox, int groupnumber, int peernumber, byte[] pk);
internal static extern int GroupGetTitle(ToxHandle tox, int groupnumber, byte[] title, uint max_length);
internal static extern int GroupGetType(ToxHandle tox, int groupnumber);
internal static extern void SelfSetStatus(ToxHandle tox, ToxUserStatus status);
internal static extern void RegisterFriendReadReceiptCallback(ToxHandle tox, ToxDelegates.CallbackReadReceiptDelegate callback, IntPtr userdata);
internal static extern bool SelfSetTyping(ToxHandle tox, uint friendNumber, [MarshalAs(UnmanagedType.Bool)]bool is_typing, ref ToxErrorSetTyping error);
internal static extern void RegisterFileReceiveCallback(ToxHandle tox, ToxDelegates.CallbackFileReceiveDelegate callback, IntPtr userdata);
internal static extern bool FileGetFileId(ToxHandle tox, uint friendNumber, uint fileNumber, byte[] fileId, ref ToxErrorFileGet error);
internal static extern void RegisterFileControlRecvCallback(ToxHandle tox, ToxDelegates.CallbackFileControlDelegate callback, IntPtr userdata);
internal static extern uint FriendAdd(ToxHandle tox, byte[] address, byte[] message, uint length, ref ToxErrorFriendAdd error);
internal static extern void RegisterFileChunkRequestCallback(ToxHandle tox, ToxDelegates.CallbackFileRequestChunkDelegate callback, IntPtr userdata);
internal static extern bool FriendExists(ToxHandle tox, uint friendNumber);
internal static extern int GroupGetNames(ToxHandle tox, int groupnumber, byte[,] names, ushort[] lengths, ushort length);
internal static extern bool FriendGetPublicKey(ToxHandle tox, uint friendNumber, byte[] publicKey, ref ToxErrorFriendGetPublicKey error);
internal static extern uint SelfGetStatusMessageSize(ToxHandle tox);
internal static extern void RegisterFriendLosslessPacketCallback(ToxHandle tox, ToxDelegates.CallbackFriendPacketDelegate callback, IntPtr userdata);
internal static extern uint GroupPeerNumberIsOurs(ToxHandle tox, int groupnumber, int peernumber);
internal static extern void SelfGetStatusMessage(ToxHandle tox, byte[] status);
internal static extern void RegisterGroupTitleCallback(ToxHandle tox, ToxDelegates.CallbackGroupTitleDelegate callback, IntPtr userdata);
internal static extern ushort SelfGetUdpPort(ToxHandle tox, ref ToxErrorGetPort error);
internal static extern void ToxLogCallback(ToxHandle tox, ToxLogLevel level, string file, uint line, string func, string message, IntPtr userdata);
internal static extern void SelfSetNospam(ToxHandle tox, uint nospam);
internal static extern bool Bootstrap(ToxHandle tox, string host, ushort port, byte[] publicKey, ref ToxErrorBootstrap error);
internal static extern void SelfSetStatusMessage(ToxHandle tox, byte[] status, uint length, ref ToxErrorSetInfo error);
internal static extern ToxConnectionStatus SelfGetConnectionStatus(ToxHandle tox);
internal static extern void SelfGetAddress(ToxHandle tox, byte[] address);
internal static extern bool FileControl(ToxHandle tox, uint friendNumber, uint fileNumber, ToxFileControl control, ref ToxErrorFileControl error);
internal static extern bool FileSeek(ToxHandle tox, uint friendNumber, uint fileNumber, ulong position, ref ToxErrorFileSeek error);
internal static extern bool FileSendChunk(ToxHandle tox, uint friendNumber, uint fileNumber, ulong position, byte[] data, uint length, ref ToxErrorFileSendChunk error);
internal static extern void Iterate(ToxHandle tox);
internal static extern uint FriendAddNoRequest(ToxHandle tox, byte[] publicKey, ref ToxErrorFriendAdd error);
internal static extern uint IterationInterval(ToxHandle tox);
internal static extern bool FriendDelete(ToxHandle tox, uint friendNumber, ref ToxErrorFriendDelete error);
internal static extern ToxConnectionStatus FriendGetConnectionStatus(ToxHandle tox, uint friendNumber, ref ToxErrorFriendQuery error);
internal static extern bool FriendGetName(ToxHandle tox, uint friendNumber, byte[] name, ref ToxErrorFriendQuery error);
internal static extern ToxUserStatus FriendGetStatus(ToxHandle tox, uint friendNumber, ref ToxErrorFriendQuery error);
internal static extern ToxUserStatus SelfGetStatus(ToxHandle tox);
internal static extern uint FriendGetStatusMessageSize(ToxHandle tox, uint friendNumber, ref ToxErrorFriendQuery error);
/// <summary> /// Initialises a new instance of toxav. /// </summary> /// <param name="tox"></param> /// <param name="settings"></param> /// <param name="max_calls"></param> public ToxAv(ToxHandle tox, ToxAvCodecSettings settings, int max_calls) { toxav = ToxAvFunctions.New(tox, max_calls); if (toxav == null || toxav.IsInvalid) throw new Exception("Could not create a new instance of toxav."); MaxCalls = max_calls; CodecSettings = settings; Invoker = new InvokeDelegate(dummyinvoker); callbacks(); }
internal static extern int GroupNumberPeers(ToxHandle tox, int groupnumber);