removed a few bugs relating to terminating sockets prior to program end.
This commit is contained in:
@@ -13,7 +13,12 @@ void NetworkInput::listen_for_clients(int port) {
|
||||
}
|
||||
|
||||
void NetworkInput::stop_listening_for_clients() {
|
||||
delete client_listener_thread;
|
||||
listening = false;
|
||||
listener.close();
|
||||
socket_selector.clear();
|
||||
|
||||
client_listener_thread->join();
|
||||
|
||||
}
|
||||
|
||||
void NetworkInput::recieve_from_clients()
|
||||
@@ -34,11 +39,12 @@ void NetworkInput::threaded_client_listener(int port) {
|
||||
listener.listen(port);
|
||||
socket_selector.add(listener);
|
||||
|
||||
while (true)
|
||||
while (listening)
|
||||
{
|
||||
// Make the selector wait for data on any socket
|
||||
if (socket_selector.wait())
|
||||
if (socket_selector.wait(sf::Time(sf::milliseconds(100))))
|
||||
{
|
||||
|
||||
// Test the listener
|
||||
if (socket_selector.isReady(listener))
|
||||
{
|
||||
|
||||
56
src/main.cpp
56
src/main.cpp
@@ -72,19 +72,27 @@ sf::Texture window_texture;
|
||||
|
||||
int main() {
|
||||
|
||||
// Keep at this at the top of main. I think it has to do with it and
|
||||
// sf::RenderWindow stepping on each others feet
|
||||
glewInit();
|
||||
|
||||
// The socket listener for interacting with the TCP streaming android controller
|
||||
NetworkInput ni;
|
||||
ni.listen_for_clients(5000);
|
||||
|
||||
|
||||
//Map _map(sf::Vector3i(0, 0, 0));
|
||||
//_map.generate_octree();
|
||||
|
||||
glewInit();
|
||||
// Currently just close it right away for debug
|
||||
ni.stop_listening_for_clients();
|
||||
|
||||
sf::RenderWindow window(sf::VideoMode(WINDOW_X, WINDOW_Y), "SFML");
|
||||
window.setMouseCursorVisible(false);
|
||||
|
||||
// =============================
|
||||
Map _map(sf::Vector3i(0, 0, 0));
|
||||
_map.generate_octree();
|
||||
// =============================
|
||||
|
||||
|
||||
|
||||
/*GL_Testing t;
|
||||
t.compile_shader("../shaders/passthrough.frag", GL_Testing::Shader_Type::FRAGMENT);
|
||||
t.compile_shader("../shaders/passthrough.vert", GL_Testing::Shader_Type::VERTEX);
|
||||
@@ -92,8 +100,6 @@ int main() {
|
||||
t.create_buffers();*/
|
||||
|
||||
// Start up the raycaster
|
||||
//Hardware_Caster *raycaster = new Hardware_Caster();
|
||||
//Hardware_Caster *raycaster = new Hardware_Caster();
|
||||
std::shared_ptr<Hardware_Caster> raycaster(new Hardware_Caster());
|
||||
|
||||
if (raycaster->init() != 1) {
|
||||
@@ -165,22 +171,12 @@ int main() {
|
||||
accumulator_time = 0.0,
|
||||
current_time = 0.0;
|
||||
|
||||
// Mouse capture
|
||||
sf::Vector2i deltas;
|
||||
sf::Vector2i fixed(window.getSize());
|
||||
sf::Vector2i prev_pos;
|
||||
bool mouse_enabled = true;
|
||||
bool reset = false;
|
||||
|
||||
|
||||
double timer_accumulator = 0.0;
|
||||
|
||||
Input input_handler;
|
||||
|
||||
camera->subscribe_to_publisher(&input_handler, vr::Event::EventType::KeyHeld);
|
||||
camera->subscribe_to_publisher(&input_handler, vr::Event::EventType::KeyPressed);
|
||||
camera->subscribe_to_publisher(&input_handler, vr::Event::EventType::MouseMoved);
|
||||
//camera->subscribe_to_publisher(&ni, vr::Event::EventType::JoystickMoved);
|
||||
handle->subscribe_to_publisher(&ni, vr::Event::EventType::JoystickMoved);
|
||||
|
||||
WindowHandler win_hand(&window);
|
||||
@@ -195,35 +191,9 @@ int main() {
|
||||
input_handler.dispatch_events();
|
||||
ni.dispatch_events();
|
||||
|
||||
|
||||
if (sf::Keyboard::isKeyPressed(sf::Keyboard::F11)) {
|
||||
while (raycaster->debug_quick_recompile() != 0);
|
||||
}
|
||||
//if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left)) {
|
||||
// light_vec.at(0).position.x -= delta_time * 100;
|
||||
//}
|
||||
//if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right)) {
|
||||
// light_vec.at(0).position.x += delta_time * 100;
|
||||
//}
|
||||
//if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up)) {
|
||||
// light_vec.at(0).position.y += delta_time * 100;
|
||||
//}
|
||||
//if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down)) {
|
||||
// light_vec.at(0).position.y -= delta_time * 100;
|
||||
//}
|
||||
//if (sf::Keyboard::isKeyPressed(sf::Keyboard::Home)) {
|
||||
// light_vec.at(0).position.z += delta_time * 100;
|
||||
//}
|
||||
//if (sf::Keyboard::isKeyPressed(sf::Keyboard::End)) {
|
||||
// light_vec.at(0).position.z -= delta_time * 100;
|
||||
//}
|
||||
//if (sf::Keyboard::isKeyPressed(sf::Keyboard::LAlt)) {
|
||||
// light_vec.at(0).position = camera->get_position();
|
||||
// light_vec.at(0).direction_cartesian = SphereToCart(camera->get_direction());
|
||||
//}
|
||||
//if (sf::Keyboard::isKeyPressed(sf::Keyboard::O)) {
|
||||
// light_vec.at(0).orbit_around_center(timer_accumulator += delta_time);
|
||||
//}
|
||||
|
||||
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Num0)) {
|
||||
std::string path = "../assets/";
|
||||
|
||||
Reference in New Issue
Block a user