var Network = (function(){

    const net = require('net');
    const event = require('./Event.js')

    const server_config = {
       port: '8181',
       handle: null 
    };

    return {
        Server: {
            start: function(resolve, reject){

                if (server_config.handle != null){
                    console.log("server is already listening");
                    reject();
                }
                else{
                    try{
                        server_config.handle = net.createServer(function(client_socket){
                            client_socket.on('data', function(client_socket){
                                console.log('got some data');
                            });
                        }).listen(server_config.port);

                        resolve();
                    }
                    catch(err){
                        reject(err);
                    }
                }
            }
        }

    };

})();

module.exports = Network;