Feature/connection state (#25)
* (cmake) add a warning about 32/64 conversion problems. * fix typo * New connection state for server code + fix OpenSSL double init bug * update README
This commit is contained in:
		
				
					committed by
					
						
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							e77b9176f3
						
					
				
				
					commit
					ee25bd0f92
				
			@@ -6,6 +6,8 @@
 | 
			
		||||
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
#include "IXConnectionState.h"
 | 
			
		||||
 | 
			
		||||
#include <utility> // pair
 | 
			
		||||
#include <string>
 | 
			
		||||
#include <set>
 | 
			
		||||
@@ -20,6 +22,8 @@ namespace ix
 | 
			
		||||
{
 | 
			
		||||
    class SocketServer {
 | 
			
		||||
    public:
 | 
			
		||||
        using ConnectionStateFactory = std::function<std::shared_ptr<ConnectionState>()>;
 | 
			
		||||
 | 
			
		||||
        SocketServer(int port = SocketServer::kDefaultPort,
 | 
			
		||||
                     const std::string& host = SocketServer::kDefaultHost,
 | 
			
		||||
                     int backlog = SocketServer::kDefaultTcpBacklog,
 | 
			
		||||
@@ -27,6 +31,8 @@ namespace ix
 | 
			
		||||
        virtual ~SocketServer();
 | 
			
		||||
        virtual void stop();
 | 
			
		||||
 | 
			
		||||
        void setConnectionStateFactory(const ConnectionStateFactory& connectionStateFactory);
 | 
			
		||||
 | 
			
		||||
        const static int kDefaultPort;
 | 
			
		||||
        const static std::string kDefaultHost;
 | 
			
		||||
        const static int kDefaultTcpBacklog;
 | 
			
		||||
@@ -60,9 +66,13 @@ namespace ix
 | 
			
		||||
        std::condition_variable _conditionVariable;
 | 
			
		||||
        std::mutex _conditionVariableMutex;
 | 
			
		||||
 | 
			
		||||
        //
 | 
			
		||||
        ConnectionStateFactory _connectionStateFactory;
 | 
			
		||||
 | 
			
		||||
        // Methods
 | 
			
		||||
        void run();
 | 
			
		||||
        virtual void handleConnection(int fd) = 0;
 | 
			
		||||
        virtual void handleConnection(int fd,
 | 
			
		||||
                                      std::shared_ptr<ConnectionState> connectionState) = 0;
 | 
			
		||||
        virtual size_t getConnectedClientsCount() = 0;
 | 
			
		||||
    };
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user