Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
#!/bin/sh browser="google-chrome" dir="node_webchat" mkdir $dir cd $dir if [ ! -f "/usr/bin/nodejs" ] then sudo apt-get install nodejs fi npm install --save express@4.10.2 npm install --save socket.io cat << EOF > server.js var app = require('express')(); var http = require('http').Server(app); var io = require('socket.io')(http); app.get('/', function(req, res){ res.sendFile(__dirname + '/index.html'); }); io.on('connection', function(socket){ socket.on('chat message', function(msg){ io.emit('chat message', msg); console.log(msg); //for server monitoring. //process.stdout.write(msg); }); }); http.listen(3000, function(){ console.log('listening on *:3000'); }); EOF cat << EOH > index.html
Socket.IO chat
Send
EOH $browser "http://127.0.0.1:3000" & $browser "http://127.0.0.1:3000" & nodejs server.js
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)