使用Node.js创build便携式在线聊天应用程序是否可行?

我想知道是否有可能使用Node.js制作一个便携式聊天应用程序。

我的意思是说,如果有一个提供Node.js聊天服务的中央网站,用户可以获取脚本代码(不pipe是基于JavaScript还是iframe ),并在他们的网站上发布聊天程序。

假设这个应用程序托pipe在chatServer.com

  1. 例如,如果用户有一个ID为chatScreen足够的表单input,并链接chatServer.com脚本之一

要么

  1. 用户可以只是iframe的聊天页面。 (例如:chatServer.com/chat/room/roomName)

要么

  1. 使用闪光灯瑞士法郎将其移入页面。

如果我没有记错的话,JSON数据不能在不同域之间交易。

你认为这个应用程序有可能吗?

我只是想知道是否可以build立它。

我看到了一些类似的networking聊天应用程序,它是用“Python twisted”+“swf”

如果你使用socket.io,它只会使用jsonp进行跨域通信。

 <script src="//chatServer.com/socket.io.js"></script> <script> var socket = io.connect('//chatServer.com'); socket.on('chat', function (data) { console.log(data); socket.emit('my other event', { my: 'data' }); }); </script> 

我遇到了问题在跨域我的代码为app.js是

  var express = require('express'), app = express(); var port = process.env.PORT || 8080; // Initialize a new socket.io object. It is bound to // the express app, which allows them to coexist. var io = require('socket.io').listen(app.listen(port)); // Require the configuration and the routes files, and pass // the app and io as arguments to the returned functions. io.use(function(socket, next) { var handshakeData = socket.request; //console.log(handshakeData); next(); }); // Require the configuration and the routes files, and pass // the app and io as arguments to the returned functions. app.use(function(req, res, next) { res.header("Access-Control-Allow-Origin", "*"); res.header("Access-Control-Allow-Headers", "X-Requested-With"); res.header("Access-Control-Allow-Methods", "GET,POST"); next(); }); require('./config')(app, io); require('./routes')(app, io); console.log('Your application is running on http://localhost:' + port);