将webrtc与节点服务器合并

时间:2014-11-04 17:19:52

标签: node.js webrtc mean-stack videochat

我已经使用node.js服务器和带有实时视频聊天的WebRTC应用程序制作了MEAN.js应用程序。两个应用程序(单独)都正常工作。现在我需要将WebRTC与MEAN.js应用程序集成。 MEAN.js应用程序(在端口3000上)中的节点server.js文件存在:

  'use strict';
/**
 * Module dependencies.
 */
var init = require('./config/init')(),
    config = require('./config/config'),
    mongoose = require('mongoose');

/**
 * Main application entry file.
 * Please note that the order of loading is important.
 */

// Bootstrap db connection
var db = mongoose.connect(config.db, function(err) {
    if (err) {
        console.error('\x1b[31m', 'Could not connect to MongoDB!');
        console.log(err);
    }
});

// Init the express application
var app = require('./config/express')(db);

// Bootstrap passport config
require('./config/passport')();

// Start the app by listening on <port>
app.listen(config.port);

// Expose app
exports = module.exports = app;

// Logging initialization
console.log('MEAN.JS application started on port ' + config.port);

和WebRTC中的server.js文件(在端口8080上)是:

// Load required modules
var http    = require("http");              // http server core module
var express = require("express");           // web framework external module
var io      = require("socket.io");         // web socket external module
var easyrtc = require("easyrtc");           // EasyRTC external module

// Setup and configure Express http server. Expect a subfolder called "static" to be the web        root.
var httpApp = express();
httpApp.use(express.static(__dirname + "/static/"));

// Start Express http server on port 8080
var webServer = http.createServer(httpApp).listen(8080);

// Start Socket.io so it attaches itself to Express server
var socketServer = io.listen(webServer, {"log level":1});

// Start EasyRTC server
var rtc = easyrtc.listen(httpApp, socketServer);

有人知道如何将这两个server.js文件合并为一个,以使MEAN.js与WebRTC一起工作吗?提前谢谢。

0 个答案:

没有答案