text: "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  var http_1 = require("http");
  var express = require("express");
  var socketIo = require("socket.io");
  var ChatServer = /** @class */ (function () {
      function ChatServer() {
          this.createApp();
          this.config();
          this.createServer();
          this.sockets();
          this.listen();
      }
      ChatServer.prototype.createApp = function () {
          this.app = express();
      };
      ChatServer.prototype.createServer = function () {
          this.server = http_1.createServer(this.app);
      };
      ChatServer.prototype.config = function () {
          this.port = process.env.PORT || ChatServer.PORT;
      };
      ChatServer.prototype.sockets = function () {
          this.io = socketIo(this.server);
      };
      ChatServer.prototype.listen = function () {
          var _this = this;
          this.server.listen(this.port, function () {
              console.log('Running server on port %s', _this.port);
          });
          this.io.on('connect', function (socket) {
              console.log('Connected client on port %s.', _this.port);
              socket.on('message', function (m) {
                  console.log('[server](message): %s', JSON.stringify(m));
                  _this.io.emit('message', m);
              });
              socket.on('disconnect', function () {
                  console.log('Client disconnected');
              });
          });
      };
      ChatServer.prototype.getApp = function () {
          return this.app;
      };
      ChatServer.PORT = 3000;
      return ChatServer;
  }());
  exports.ChatServer = ChatServer;
  