diff --git a/example/.gitignore b/example/.gitignore
new file mode 100644
index 0000000..a56a7ef
--- /dev/null
+++ b/example/.gitignore
@@ -0,0 +1,2 @@
+node_modules
+
diff --git a/example/index.html b/example/index.html
new file mode 100644
index 0000000..4a7ac34
--- /dev/null
+++ b/example/index.html
@@ -0,0 +1,88 @@
+
+
+
+ Socket.IO chat
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/example/index.js b/example/index.js
new file mode 100644
index 0000000..9c7e337
--- /dev/null
+++ b/example/index.js
@@ -0,0 +1,25 @@
+var app = require('express')();
+var http = require('http').Server(app);
+var io = require('socket.io')(http);
+var socketioJwt = require('socketio-jwt');
+
+app.get('/', function(req, res){
+ res.sendFile(__dirname + '/index.html');
+});
+
+io
+ .on('connection', socketioJwt.authorize({
+ secret: Buffer('YOUR_CLIENT_SECRET', 'base64'),
+ timeout: 15000 // 15 seconds to send the authentication message
+ }))
+ .on('authenticated', function(socket){
+ console.log('connected & authenticated: ' + socket.decoded_token.toString());
+ socket.on('chat message', function(msg){
+ debugger;
+ io.emit('chat message', msg);
+ });
+ });
+
+http.listen(3001, function(){
+ console.log('listening on *:3001');
+});
diff --git a/example/package.json b/example/package.json
new file mode 100644
index 0000000..f4ab4e8
--- /dev/null
+++ b/example/package.json
@@ -0,0 +1,10 @@
+{
+ "name": "socket-chat-example",
+ "version": "0.0.1",
+ "description": "my first socket.io app",
+ "dependencies": {
+ "express": "^4.10.2",
+ "socket.io": "^1.3.6",
+ "socketio-jwt": "^4.3.1"
+ }
+}
diff --git a/example/public/index.html b/example/public/index.html
deleted file mode 100644
index dee5bb6..0000000
--- a/example/public/index.html
+++ /dev/null
@@ -1,64 +0,0 @@
-
-
-
- Socket.io with JWTs
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/example/server.js b/example/server.js
deleted file mode 100644
index 274635a..0000000
--- a/example/server.js
+++ /dev/null
@@ -1,54 +0,0 @@
-var express = require('express');
-var http = require('http');
-
-var socketIo = require('socket.io');
-var socketio_jwt = require('../'); //require('socketio-jwt');
-
-var jwt = require('jsonwebtoken');
-var jwt_secret = 'foo bar big secret';
-
-var app = express();
-
-var serveStatic = require('serve-static');
-var bodyParser = require('body-parser');
-
-app.use(serveStatic('public', {'index': ['index.html']}));
-app.use(bodyParser.json());
-
-app.post('/login', function (req, res) {
- var profile = {
- first_name: 'John',
- last_name: 'Doe',
- email: 'john@doe.com',
- id: 123
- };
-
- // We are sending the profile inside the token
- var token = jwt.sign(profile, jwt_secret, { expiresInMinutes: 60*5 });
-
- res.json({token: token});
-});
-
-var server = http.createServer(app);
-var sio = socketIo.listen(server);
-
-sio.use(socketio_jwt.authorize({
- secret: jwt_secret,
- handshake: true
-}));
-
-sio.sockets
- .on('connection', function (socket) {
- console.log(socket.decoded_token.email, 'connected');
- socket.on('ping', function (m) {
- socket.emit('pong', m);
- });
- });
-
-setInterval(function () {
- sio.sockets.emit('time', Date());
-}, 5000);
-
-server.listen(9000, function () {
- console.log('listening on http://localhost:9000');
-});
\ No newline at end of file