Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
DTrejo committed Oct 16, 2010
0 parents commit 792d31d
Show file tree
Hide file tree
Showing 12 changed files with 2,371 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
src/*.swp
3 changes: 3 additions & 0 deletions .gitmodules
@@ -0,0 +1,3 @@
[submodule "lib/socket.io-node"]
path = lib/socket.io-node
url = git://github.com/LearnBoost/Socket.IO-node.git
1 change: 1 addition & 0 deletions lib/socket.io-node
Submodule socket.io-node added at 52d7c5
6 changes: 6 additions & 0 deletions public/controller.xml
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Response>
<Gather action="/digits.xml" method="POST" timeout="9999" numDigits="1" finishOnKey="">
<Say>Press sum buttons!</Say>
</Gather>
</Response>
35 changes: 35 additions & 0 deletions public/css/style.css
@@ -0,0 +1,35 @@
body {
width: 33em;
color: #D6D7D9;
background: #555;
margin: 3em auto;
font-family: 'Nobile', times, Times New Roman, times-roman, georgia, serif;
font-size: 101%;
}

h1 > a, h1 > a:focus {
color: #D4E122;
}
a, a:focus {
color: #D4E122;
}

h2, .number{color:lightsteelblue;}

ol{
text-shadow: 1px 1px 1px #444;
margin-top: 1.5em;
margin-bottom: 1.5em;
}
li {
font-size: 1.5em;
margin-left: .6em;
}
li:last-child{margin-bottom:0em;}
pre {
border-left: 3px solid #888;
}
pre#events{
min-height: 3em;
padding-left: 1em;
}
6 changes: 6 additions & 0 deletions public/digits.xml
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Response>
<Gather action="/digits.xml" method="POST" timeout="9999" numDigits="1" finishOnKey="">
<Say>Pew!</Say>
</Gather>
</Response>
Binary file added public/favicon.ico
Binary file not shown.
Binary file added public/favicon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
100 changes: 100 additions & 0 deletions public/index.html
@@ -0,0 +1,100 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Tanktacular</title>
<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="/socket.io/socket.io.js"></script>
<script type="text/javascript" src="js/tanks.js"></script>
<link rel="shortcut icon" href="/favicon.png">
<link rel="stylesheet" href="css/style.css">
<link href='http://fonts.googleapis.com/css?family=Nobile&subset=latin' rel='stylesheet' type='text/css'>
</head>

<body>

<script>
var events;
$(document).ready(function() {
events = $('#events');
});

// so console.log always works
if (!window.console) {
window.console = new function() {
this.log = function(str) { /* alert(str) */ };
};
}

// null defaults to the domain that this file is served from.
var socket = new io.Socket(null, {port: 80}); // IMPORTANT. HAVE THE PORT CORRECT.

socket.connect();

socket.on('message', function(obj) {
console.log('message:');
console.log(obj);

$('<span/>').text(JSON.stringify(obj) + '\n')
.appendTo(events);
});

socket.on('disconnect', function(obj) {
console.log('disconnect');
console.log(obj);
$('<span/>').text(JSON.stringify(obj) + '\n')
.appendTo(events);
socket.connect();
// attempt to reconnect. I wonder if this makes it loop?
// This attempts to fix the problem where you need to refresh
// before the server can talk to you. This problem happens
// whenever the server gets restarted.
});
</script>

<h1><a href="http://github.com/dtrejo/">Control a game* with your phone!</a></h1>
<p>* or anything!</p>
<ol>
<li>Call <span class="number">(415) 599-2671</span></li>
<li>Enter PIN: <span class="number">1419-4378</span> (normal users would not need to do this)</li>
<li>Press some buttons and see them transmitted to this window!</li>
</ol>
<p>As you and others press buttons on their phones, the event will show up below.</p>

<h2>Try it out</h2>
<p>call in <a href="/controller.xml?From=555-501-1337&Digits=9" target="_blank">/controller.xml?From=555-501-1337&Digits=9</a><br>
press 9 <a href="/digits.xml?From=555-501-1337&Digits=9" target="_blank">/digits.xml?From=555-501-1337&Digits=9</a><br>
press 2 <a href="/digits.xml?From=555-501-1337&Digits=9" target="_blank">/digits.xml?From=555-501-1337&Digits=2</a><br>
hang up <a href="/digits.xml?From=555-501-1337&Digits=9&CallStatus=completed" target="_blank">/digits.xml?From=555-501-1337&Digits=9&CallStatus=completed</a>
</p>

<h2>Events show below as people and phones hit the above URLs</h2>
<pre id="events"></pre>

<h2>The Basics</h2>
<p>controller.xml and digits.xml are POSTed to by Twilio. This is important, because some servers refuse to serve files that are POSTed to :|</p>
<p>Twilio adds parameters when it hits asks for those files, which is how the server finds out about keypresses and new connections.</p>
<p>If you buy a number, remember to appropriately set your Voice URL, <code>http://dtrejo.no.de/controller.xml</code>, and your StatusCallback URL, <code>http://dtrejo.no.de/digits.xml</code></p>

<h2>controller.xml</h2>
<pre>
&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
&lt;Response&gt;
&lt;Gather action="/digits.xml" method="POST" timeout="9999" numDigits="1" finishOnKey=""&gt;
&lt;Say&gt;Press sum buttons!&lt;/Say&gt;
&lt;/Gather&gt;
&lt;/Response&gt;</pre>

<h2>digits.xml</h2>
<pre>
&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
&lt;Response&gt;
&lt;Gather action="/digits.xml" method="POST" timeout="9999" numDigits="1" finishOnKey=""&gt;
&lt;Say&gt;Pew!&lt;/Say&gt;
&lt;/Gather&gt;
&lt;/Response&gt;</pre>

<p>&mdash; Source at <a href="http://github.com/dtrejo/">SOURCEURL David Trejo</a></p>

</body>
</html>

0 comments on commit 792d31d

Please sign in to comment.