我从这个页面上学到了一些知识 - > https://github.com/Automattic/socket.io/issues/1846
我的问题是:Socket是否需要SSL支持才能工作?
我已经苦苦思索了很长时间,但是还没有找到解决方案。请问有没有聪明的人可以帮忙解决这个难题?
我的应用程序代码:var express = require("express");
var app = express();
var http = require('http').Server(app);
var io = require('socket.io')(http);
app.use(express.static(__dirname + '/html'));
http.listen(process.env.PORT || 3000, function(){
console.log('listening on *:', process.env.PORT || 3000);
new shell.Shell(app, io);
});
app.use(function(request, response, next){
response.header("Access-Control-Allow-Origin", "*");
response.header("Access-Control-Allow-Methods", "GET,PUT,POST,DELETE,OPTIONS");
response.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, X-Auth-Token");
request.id = self.id++;
next();
});
var self = this;
app.get("/", function(request, response) {
response.end("");
});
app.get("/entitlement/:uri", function(request, response){
self.delegate.entitlement(request, response);
});
app.get("/speakers", function(request, response) {
self.delegate.speaker(request, response);
});
app.get("/speakers/:id", function(request, response) {
self.delegate.speaker(request, response);
});
app.get("/sponsors", function(request, response){
self.delegate.sponsor(request, response);
});
app.get("/sponsors/:id", function(request, response) {
self.delegate.sponsor(request, response);
});
app.get("/agendas", function(request, response) {
self.delegate.agenda(request, response);
});
app.get("/agendas/:id", function(request, response) {
self.delegate.agenda(request, response);
});
app.get("/sessions/:id", function(request, response){
self.delegate.agenda(request, response);
});
app.get("/attendees", function(request, response) {
//self.delegate.attendee(request, response);
});
///attendees/:id to get chat history
io.on("connection", function(socket){
//self.delegate.connection(io, socket, null);
socket.on('get-age-in-dog-years', function(data, fn) {
console.log(data);
fn(data.age * 7) ;
});
socket.on("chat", function(chat){
//self.delegate.chat(io, socket, chat);
});
socket.on("disconnect", function(){
//self.delegate.disconnect(io, socket)
});
});
},