Netork control of the camera now works, slight hitch every few seconds though. Not sure how to track that down
This commit is contained in:
@@ -25,8 +25,6 @@ private:
|
||||
|
||||
void transpose_sf_events(std::list<sf::Event> event_queue);
|
||||
|
||||
// Network controller class
|
||||
|
||||
std::vector<sf::Keyboard::Key> held_keys;
|
||||
std::vector<sf::Mouse::Button> held_mouse_buttons;
|
||||
|
||||
@@ -36,7 +34,6 @@ private:
|
||||
private:
|
||||
|
||||
std::list<std::unique_ptr<vr::Event>> event_queue;
|
||||
|
||||
};
|
||||
|
||||
class WindowHandler : public VrEventSubscriber {
|
||||
|
||||
44
include/NetworkInput.h
Normal file
44
include/NetworkInput.h
Normal file
@@ -0,0 +1,44 @@
|
||||
#include <SFML/Network.hpp>
|
||||
#include <thread>
|
||||
#include "Event.hpp"
|
||||
#include "Pub_Sub.h"
|
||||
#include <list>
|
||||
|
||||
struct CustomPacket {
|
||||
|
||||
char data[1024];
|
||||
int position = 0;
|
||||
int size = 12;
|
||||
|
||||
};
|
||||
|
||||
class NetworkInput : public VrEventPublisher {
|
||||
public:
|
||||
NetworkInput();
|
||||
|
||||
void listen_for_clients(int port);
|
||||
void stop_listening_for_clients();
|
||||
|
||||
void recieve_from_clients();
|
||||
void stop_recieving_from_clients();
|
||||
|
||||
void generate_events();
|
||||
void dispatch_events();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
std::list<std::unique_ptr<vr::Event>> event_queue;
|
||||
|
||||
std::vector<sf::TcpSocket*> client_sockets;
|
||||
sf::SocketSelector socket_selector;
|
||||
|
||||
std::thread *client_listener_thread;
|
||||
std::thread *client_reciever_thread;
|
||||
|
||||
void threaded_client_listener(int port);
|
||||
void threaded_client_reciever();
|
||||
|
||||
sf::TcpListener listener;
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user