Commit f25294b364fe194579475b3b9bdc4ba5c9977767
1 parent
6a447a03
Exists in
master
and in
1 other branch
Corrige contador de tentativas de conexão
Showing
1 changed file
with
6 additions
and
5 deletions
Show diff stats
renderer/src/renderer.cpp
| 1 | #include "renderer.h" | 1 | #include "renderer.h" |
| 2 | -#include <iostream> | ||
| 3 | 2 | ||
| 4 | Renderer::Renderer(char* path_Contents, char* id) { | 3 | Renderer::Renderer(char* path_Contents, char* id) { |
| 5 | this->pathOutVideo = path_Contents; | 4 | this->pathOutVideo = path_Contents; |
| @@ -41,7 +40,6 @@ void Renderer::executeServerScript() { | @@ -41,7 +40,6 @@ void Renderer::executeServerScript() { | ||
| 41 | 40 | ||
| 42 | command.append(" && ").append("python render.py ") | 41 | command.append(" && ").append("python render.py ") |
| 43 | .append(userID).append(" >/dev/null 2>&1 &"); | 42 | .append(userID).append(" >/dev/null 2>&1 &"); |
| 44 | - | ||
| 45 | system(command.c_str()); | 43 | system(command.c_str()); |
| 46 | } | 44 | } |
| 47 | 45 | ||
| @@ -53,11 +51,14 @@ void Renderer::connectToUnityPlayer() { | @@ -53,11 +51,14 @@ void Renderer::connectToUnityPlayer() { | ||
| 53 | PRINTL(util::_DEBUG, "Conectando ao UnityPlayer...\n"); | 51 | PRINTL(util::_DEBUG, "Conectando ao UnityPlayer...\n"); |
| 54 | while(!cSocket->isConnected()){ | 52 | while(!cSocket->isConnected()){ |
| 55 | try{ | 53 | try{ |
| 54 | + | ||
| 56 | cSocket->connect(addr, PORT); | 55 | cSocket->connect(addr, PORT); |
| 57 | - i++; | ||
| 58 | - sleep(1); | 56 | + |
| 59 | }catch(lavidlib::SocketException &ex){ | 57 | }catch(lavidlib::SocketException &ex){ |
| 60 | - if(i == 10){ // Numeros de tentativas (pode ser alterado) | 58 | + if(i < 10) { // Numeros de tentativas de conexão (pode ser alterado) |
| 59 | + i++; | ||
| 60 | + sleep(1); | ||
| 61 | + }else{ | ||
| 61 | PRINTL(util::_ERROR, "Número de tentativas de conexão excedido!\n"); | 62 | PRINTL(util::_ERROR, "Número de tentativas de conexão excedido!\n"); |
| 62 | throw lavidlib::RuntimeException(ex.getMessage().c_str()); | 63 | throw lavidlib::RuntimeException(ex.getMessage().c_str()); |
| 63 | } | 64 | } |