mirror of
https://github.com/danog/libtgvoip.git
synced 2025-01-22 13:01:21 +01:00
Updated the CXWrapper to use events instead of IStateCallback
This commit is contained in:
parent
d348e56436
commit
afc4453acd
@ -41,7 +41,6 @@ VoIPControllerWrapper::VoIPControllerWrapper(){
|
||||
controller->implData=(void*)this;
|
||||
controller->SetStateCallback(VoIPControllerWrapper::OnStateChanged);
|
||||
controller->SetSignalBarsCountCallback(VoIPControllerWrapper::OnSignalBarsChanged);
|
||||
stateCallback=nullptr;
|
||||
}
|
||||
|
||||
VoIPControllerWrapper::~VoIPControllerWrapper(){
|
||||
@ -86,10 +85,6 @@ void VoIPControllerWrapper::SetNetworkType(NetworkType type){
|
||||
controller->SetNetworkType((int)type);
|
||||
}
|
||||
|
||||
void VoIPControllerWrapper::SetStateCallback(IStateCallback^ callback){
|
||||
stateCallback=callback;
|
||||
}
|
||||
|
||||
void VoIPControllerWrapper::SetMicMute(bool mute){
|
||||
controller->SetMicMute(mute);
|
||||
}
|
||||
@ -142,13 +137,11 @@ void VoIPControllerWrapper::OnSignalBarsChanged(VoIPController* c, int count){
|
||||
}
|
||||
|
||||
void VoIPControllerWrapper::OnStateChangedInternal(int state){
|
||||
if(stateCallback)
|
||||
stateCallback->OnCallStateChanged((CallState)state);
|
||||
CallStateChanged(this, (CallState)state);
|
||||
}
|
||||
|
||||
void VoIPControllerWrapper::OnSignalBarsChangedInternal(int count){
|
||||
if(stateCallback)
|
||||
stateCallback->OnSignalBarsChanged(count);
|
||||
SignalBarsChanged(this, count);
|
||||
}
|
||||
|
||||
void VoIPControllerWrapper::SetConfig(double initTimeout, double recvTimeout, DataSavingMode dataSavingMode, bool enableAEC, bool enableNS, bool enableAGC, Platform::String^ logFilePath, Platform::String^ statsDumpFilePath){
|
||||
|
@ -58,10 +58,11 @@ namespace libtgvoip{
|
||||
SOCKS5
|
||||
};
|
||||
|
||||
public interface class IStateCallback{
|
||||
void OnCallStateChanged(CallState newState);
|
||||
void OnSignalBarsChanged(int count);
|
||||
};
|
||||
ref class VoIPControllerWrapper;
|
||||
public delegate void CallStateChangedEventHandler(VoIPControllerWrapper^ sender, CallState newState);
|
||||
|
||||
ref class VoIPControllerWrapper;
|
||||
public delegate void SignalBarsChangedEventHandler(VoIPControllerWrapper^ sender, int newCount);
|
||||
|
||||
public ref class VoIPControllerWrapper sealed{
|
||||
public:
|
||||
@ -71,7 +72,6 @@ namespace libtgvoip{
|
||||
void Connect();
|
||||
void SetPublicEndpoints(const Platform::Array<Endpoint^>^ endpoints, bool allowP2P);
|
||||
void SetNetworkType(NetworkType type);
|
||||
void SetStateCallback(IStateCallback^ callback);
|
||||
void SetMicMute(bool mute);
|
||||
void SetEncryptionKey(const Platform::Array<uint8>^ key, bool isOutgoing);
|
||||
void SetConfig(double initTimeout, double recvTimeout, DataSavingMode dataSavingMode, bool enableAEC, bool enableNS, bool enableAGC, Platform::String^ logFilePath, Platform::String^ statsDumpFilePath);
|
||||
@ -85,13 +85,16 @@ namespace libtgvoip{
|
||||
static void UpdateServerConfig(Platform::String^ json);
|
||||
static void SwitchSpeaker(bool external);
|
||||
//static Platform::String^ TestAesIge();
|
||||
|
||||
event CallStateChangedEventHandler^ CallStateChanged;
|
||||
event SignalBarsChangedEventHandler^ SignalBarsChanged;
|
||||
|
||||
private:
|
||||
static void OnStateChanged(tgvoip::VoIPController* c, int state);
|
||||
static void OnSignalBarsChanged(tgvoip::VoIPController* c, int count);
|
||||
void OnStateChangedInternal(int state);
|
||||
void OnSignalBarsChangedInternal(int count);
|
||||
tgvoip::VoIPController* controller;
|
||||
IStateCallback^ stateCallback;
|
||||
};
|
||||
|
||||
ref class MicrosoftCryptoImpl{
|
||||
|
Loading…
x
Reference in New Issue
Block a user