@@ -122,7 +122,7 @@ CClient::CClient ( const quint16 iPortNumber,
122122 QObject::connect ( &Channel, &CChannel::ConClientListMesReceived, this , &CClient::OnConClientListMesReceived );
123123 QObject::connect ( &Channel, &CChannel::ConClientListMesReceived, this , &CClient::ConClientListMesReceived );
124124
125- QObject::connect ( &Channel, &CChannel::Disconnected , this , &CClient::Disconnected );
125+ QObject::connect ( &Channel, &CChannel::DisconnectClient , this , &CClient::Disconnect );
126126
127127 QObject::connect ( &Channel, &CChannel::NewConnection, this , &CClient::OnNewConnection );
128128
@@ -907,51 +907,48 @@ void CClient::Stop()
907907
908908// / @method
909909// / @brief Connects to strServerAddress
910- // / @emit Connecting (strServerName) if the client wasn't running and SetServerAddr returned true.
910+ // / @emit Connecting (strServerName) if the client wasn't running and SetServerAddr was valid
911+ // / @emit ConnectingFailed (error) if an error occurred
911912// / @param strServerAddress - the server address to connect to
912913// / @param strServerName - the String argument to be passed to Connecting()
913- // / @result true if client wasn't running and SetServerAddr returned true, false otherwise
914- bool CClient::Connect ( QString strServerAddress, QString strServerName )
914+ void CClient::Connect ( QString strServerAddress, QString strServerName )
915915{
916- if ( !IsRunning () )
917- {
918- // Set server address and connect if valid address was supplied
919- if ( SetServerAddr ( strServerAddress ) )
916+ try {
917+ if ( !IsRunning () )
920918 {
921-
922- Start ();
923-
924- emit Connecting ( strServerName );
925-
926- return true ;
919+ // Set server address and connect if valid address was supplied
920+ if ( SetServerAddr ( strServerAddress ) )
921+ {
922+ Start ();
923+ emit Connecting ( strServerName );
924+ }
925+ else {
926+ throw CGenErr ( " Received invalid server address. Please check for typos in the provided server address." );
927+ }
927928 }
928929 }
929-
930- return false ;
930+ catch ( const CGenErr& generr )
931+ {
932+ Disconnect ();
933+ emit ConnectingFailed ( generr.GetErrorText () );
934+ }
931935}
932936
933937// / @method
934- // / @brief Disconnects client
938+ // / @brief Disconnects client. If the client is not running, it just stops Sound
935939// / @emit Disconnected
936- // / @result true if client wasn't running, false otherwise
937- bool CClient::Disconnect ()
940+ void CClient::Disconnect ()
938941{
939942 if ( IsRunning () )
940943 {
941944 Stop ();
942-
943945 emit Disconnected ();
944-
945- return true ;
946946 }
947947 else
948948 {
949- // make sure sound is stopped too
949+ // make sure sound is stopped in any case
950950 Sound.Stop ();
951-
952951 emit Disconnected ();
953-
954- return false ;
955952 }
956953}
957954
0 commit comments