This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function () { | |
$('#target').click(function () { | |
$('#target').animate({top: '-200', opacity: 0.1}, 3000, function () { | |
socket.emit('volley', {'text': 'Shot made to server...'}); | |
}); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var socket = io.connect('http://localhost:4000'); | |
socket.on('connect', function () { | |
socket.on('return', function (data) { | |
$('#target').animate({top: '500', opacity: 1}, 3000); | |
}); | |
socket.on('player', function(data){ | |
if(data.player !== 0){ | |
$('#target').css({"top": '-220px',"opacity": "0.1"}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var playernum = 0; | |
io.sockets.on('connection', function (socket) { | |
console.log('connected successfully...'); | |
playernum === 1 ? playernum = 0 : playernum++; | |
socket.emit('player', {'player': playernum}); | |
socket.on('volley', function (input) { | |
socket.broadcast.emit('return', {'data': 1}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function handler (req, res) { | |
fs.readFile(__dirname + '/index.html', | |
function (err, data) { | |
if (err) { | |
res.writeHead(500); | |
return res.end('Error loading index.html'); | |
} | |
res.writeHead(200); | |
res.end(data); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var app = require('http').createServer(handler) | |
, io = require('socket.io').listen(app) | |
, fs = require('fs'); | |
app.listen(4000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>socket.io Test</title> | |
<style> | |
html { | |
background: url('http://166.78.51.174/woodfloor.png') no-repeat 0 0 scroll; | |
background-color: #0C0C0C; | |
background-size: 100% 100%; | |
height: 100%; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var app = require('http').createServer(handler) | |
, io = require('socket.io').listen(app) | |
, fs = require('fs'); | |
app.listen(4000); | |
function handler (req, res) { | |
fs.readFile(__dirname + '/index.html', | |
function (err, data) { | |
if (err) { |