Commit a0edc9145840ac292e3a932153708951beae9999
1 parent
83d525e3
Exists in
master
and in
1 other branch
Correção na conexão com o unityPlayer
Showing
1 changed file
with
14 additions
and
8 deletions
Show diff stats
renderer/src/renderer.cpp
| ... | ... | @@ -42,21 +42,28 @@ void Renderer::executeServerScript() { |
| 42 | 42 | .append(userID).append(" >/dev/null 2>&1 &"); |
| 43 | 43 | |
| 44 | 44 | system(command.c_str()); |
| 45 | - sleep(4); //tempo para inicializar o player | |
| 46 | 45 | } |
| 47 | 46 | |
| 48 | 47 | void Renderer::connectToUnityPlayer() { |
| 49 | 48 | try{ |
| 49 | + int i = 0; // Contador de tentativas | |
| 50 | 50 | static InetAddress* addr = InetAddress::createByName(HOST); |
| 51 | + | |
| 52 | + PRINTL(util::_DEBUG, "Conectando ao UnityPlayer...\n"); | |
| 51 | 53 | while(!cSocket->isConnected()){ |
| 52 | - PRINTL(util::_DEBUG, "Conectando ao UnityPlayer...\n"); | |
| 53 | - cSocket->connect(addr, PORT); | |
| 54 | - sleep(1); | |
| 54 | + try{ | |
| 55 | + cSocket->connect(addr, PORT); | |
| 56 | + i++; | |
| 57 | + sleep(1); | |
| 58 | + }catch(lavidlib::SocketException &ex){ | |
| 59 | + if(i == 7){ // Numeros de tentativas (pode ser alterado) | |
| 60 | + PRINTL(util::_ERROR, "Número de tentativas de conexão excedido!\n"); | |
| 61 | + throw lavidlib::RuntimeException(ex.getMessage().c_str()); | |
| 62 | + } | |
| 63 | + } | |
| 55 | 64 | } |
| 56 | 65 | }catch(lavidlib::UnknownHostException &ex){ |
| 57 | 66 | throw lavidlib::RuntimeException(ex.getMessage().c_str()); |
| 58 | - }catch(lavidlib::SocketException &ex){ | |
| 59 | - throw lavidlib::RuntimeException(ex.getMessage().c_str()); | |
| 60 | 67 | } |
| 61 | 68 | } |
| 62 | 69 | |
| ... | ... | @@ -129,8 +136,6 @@ void Renderer::waitScreenShots() { |
| 129 | 136 | } |
| 130 | 137 | |
| 131 | 138 | void Renderer::renderVideo() { |
| 132 | - PRINTL(util::_INFO, "Gerando vídeo...\n"); | |
| 133 | - | |
| 134 | 139 | string command = "ffmpeg -y -loglevel quiet -framerate 30 -i "; |
| 135 | 140 | command.append(PATH_SCREENS).append(userID).append("/frame_%d.png ") |
| 136 | 141 | .append("-vcodec libx264 -pix_fmt yuv420p ").append(pathOutVideo); |
| ... | ... | @@ -157,6 +162,7 @@ void Renderer::Run() { |
| 157 | 162 | } |
| 158 | 163 | } |
| 159 | 164 | |
| 165 | + PRINTL(util::_INFO, "Gerando vídeo...\n"); | |
| 160 | 166 | receiveGlosa(END_FLAG, -1); //Quando a fila estiver vazia, a flag "FINALIZE" será enviada |
| 161 | 167 | try{ |
| 162 | 168 | exportGlosa(); | ... | ... |