We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I built an error handler...
// server code....
var express = require('express.io'); var app = express().http().io();
function middleware_errorhandler(err, req, res, next) { var env = 'development'; switch (env) { case 'development': console.log('Err:',err); res.statusCode = 500; res.setHeader('Content-Type', 'text/plain'); var errmsg = err.message+'\n'; errmsg += err.status+'\n'; errmsg += err.stack+'\n'; res.end(errmsg); break; default: res.end('Server error'); }; }
var clienthtml = ' \
io-on<\/p> \ <\/body> \ <\/html> \ ';
function body(req, res, next) { res.setHeader('Content-Type', 'text/html'); res.end(clienthtml); }
var ioroute = function (rte,iox) { app.io.route(rte, function(req) { try { console.log('ioroute is trying...'); iox(req); } catch(err) { console.log('Oopzzz an err:',err); } }); };
ioroute('whatsoke',function(req) { console.log('Whatzzzokeeee...'); req.io.emit('yooo', {yoholo:"Yoho!"}) ; });
ioroute('whatserr',function(req) { console.log('Whatzzzerrrrrrr...'); foo(); req.io.emit('yooo', {yoholo:"Yoho!"}) ; });
app.use(body); // the body ... app.use(middleware_errorhandler);
app.listen(5000); console.log('Server started @ 5000');
The text was updated successfully, but these errors were encountered:
fix issue techpines#101 cookieParser breaks when a page reloads
5e9d223
d283b0e
Conflicts: lib/index.coffee
No branches or pull requests
I built an error handler...
// server code....
var express = require('express.io');
var app = express().http().io();
function middleware_errorhandler(err, req, res, next) {
var env = 'development';
switch (env) {
case 'development':
console.log('Err:',err);
res.statusCode = 500;
res.setHeader('Content-Type', 'text/plain');
var errmsg = err.message+'\n';
errmsg += err.status+'\n';
errmsg += err.stack+'\n';
res.end(errmsg);
break;
default:
res.end('Server error');
};
}
var clienthtml = ' \
\ \ \ \ <script src="//code.jquery.com/jquery-1.10.2.js"></script> \ <script src="/socket.io/socket.io.js"></script> \ <script> \ var socket = io.connect(); \ function onc(wheretogo) { \ $("#ioon").html("Clicked"); \ if (wheretogo) { socket.emit("whatserr") } \ else { socket.emit("whatsoke") } \ }; \ socket.on("yooo", function(data) { $("#ioon").html(data.yoholo) }); \ <\/script> \ <\/head> \ \Yo world!<\/h1> \ Emit-me-err<\/button> \ Emit-me-oke<\/button> \
io-on<\/p> \ <\/body> \ <\/html> \ ';
function body(req, res, next) {
res.setHeader('Content-Type', 'text/html');
res.end(clienthtml);
}
var ioroute = function (rte,iox) {
app.io.route(rte, function(req) {
try {
console.log('ioroute is trying...');
iox(req);
}
catch(err) {
console.log('Oopzzz an err:',err);
}
});
};
ioroute('whatsoke',function(req) {
console.log('Whatzzzokeeee...');
req.io.emit('yooo', {yoholo:"Yoho!"}) ;
});
ioroute('whatserr',function(req) {
console.log('Whatzzzerrrrrrr...');
foo();
req.io.emit('yooo', {yoholo:"Yoho!"}) ;
});
app.use(body); // the body ...
app.use(middleware_errorhandler);
app.listen(5000);
console.log('Server started @ 5000');
The text was updated successfully, but these errors were encountered: