text: // server.js
  
  // set up ======================================================================
  // get all the tools we need
  var express  = require('express');
  var app      = express();
  var port     = process.env.PORT || 443;
  var mongoose = require('mongoose');
  var passport = require('passport');
  var flash    = require('connect-flash');
  
  var morgan       = require('morgan');
  var cookieParser = require('cookie-parser');
  var bodyParser   = require('body-parser');
  var session      = require('express-session');
  
  //var serveStatic = require('serve-static');  // serve static files
  var socketIo = require("socket.io");        // web socket external module
  var easyrtc = require("easyrtc");               // EasyRTC external module
  
  var configDB = require('./config/database.js');
  
  // configuration ===============================================================
  mongoose.connect(configDB.url); // connect to our database
  
  require('./config/passport')(passport); // pass passport for configuration
  
  // set up our express application
  app.use(morgan('dev')); // log every request to the console
  app.use(cookieParser()); // read cookies (needed for auth)
  app.use(bodyParser.json()); // get information from html forms
  app.use(bodyParser.urlencoded({ extended: true }));
  
  app.set('view engine', 'ejs'); // set up ejs for templating
  
  // required for passport
  app.use(session({
      secret: 'ilovescotchscotchyscotchscotch', // session secret
      resave: true,
      saveUninitialized: true
  }));
  app.use(passport.initialize());
  app.use(passport.session()); // persistent login sessions
  app.use(flash()); // use connect-flash for flash messages stored in session
  
  // routes ======================================================================
  require('./app/routes.js')(app, passport); // load our routes and pass in our app and fully configured passport
  
  // launch ======================================================================
  
  var fs      = require("fs");
  var https    = require("https");
  var webServer = https.createServer({
      key:  fs.readFileSync("../ssl/private.key"),
      cert: fs.readFileSync("../ssl/certificate.crt")
  },app);
  
  
  // Start Socket.io so it attaches itself to Express server
  var socketServer = socketIo.listen(webServer, {"log level":1});
  
  easyrtc.setOption("logLevel", "debug");
  
  // Overriding the default easyrtcAuth listener, only so we can directly access its callback
  easyrtc.events.on("easyrtcAuth", function(socket, easyrtcid, msg, socketCallback, callback) {
      easyrtc.events.defaultListeners.easyrtcAuth(socket, easyrtcid, msg, socketCallback, function(err, connectionObj){
          if (err || !msg.msgData || !msg.msgData.credential || !connectionObj) {
              callback(err, connectionObj);
              return;
          }
  
          connectionObj.setField("credential", msg.msgData.credential, {"isShared":false});
  
          console.log("["+easyrtcid+"] Credential saved!", connectionObj.getFieldValueSync("credential"));
  
          callback(err, connectionObj);
      });
  });
  
  // To test, lets print the credential to the console for every room join!
  easyrtc.events.on("roomJoin", function(connectionObj, roomName, roomParameter, callback) {
      console.log("["+connectionObj.getEasyrtcid()+"] Credential retrieved!", connectionObj.getFieldValueSync("credential"));
      easyrtc.events.defaultListeners.roomJoin(connectionObj, roomName, roomParameter, callback);
  });
  
  // Start EasyRTC server
  var rtc = easyrtc.listen(app, socketServer, null, function(err, rtcRef) {
      console.log("Initiated");
  
      rtcRef.events.on("roomCreate", function(appObj, creatorConnectionObj, roomName, roomOptions, callback) {
          console.log("roomCreate fired! Trying to create: " + roomName);
  
          appObj.events.defaultListeners.roomCreate(appObj, creatorConnectionObj, roomName, roomOptions, callback);
      });
  });
  
  webServer.listen(443, function () {
      console.log('listening on http://localhost:443');
  });
  
  //app.listen(port);
  console.log('The magic happens on port ' + port);
  