Skip to content

Instantly share code, notes, and snippets.

View AlphaT7's full-sized avatar

Jamison Winters AlphaT7

View GitHub Profile
@AlphaT7
AlphaT7 / socket-cheatsheet.js
Created November 4, 2017 18:33 — forked from alexpchin/socket-cheatsheet.js
A quick cheatsheet for socket.io
// sending to sender-client only
socket.emit('message', "this is a test");
// sending to all clients, include sender
io.emit('message', "this is a test");
// sending to all clients except sender
socket.broadcast.emit('message', "this is a test");
// sending to all clients in 'game' room(channel) except sender
@AlphaT7
AlphaT7 / client.js
Last active August 11, 2017 21:22 — forked from sahat/client.js
Calculate client-server latency using socket.io
var socket = io.connect('http://localhost');
var startTime;
setInterval(function() {
startTime = Date.now();
socket.emit('client2server');
}, 2000);
socket.on('server2client', function() {
latency = Date.now() - startTime;
<html>
<head>
<title>Simple Line Graph using SVG and d3.js</title>
<script src="http://mbostock.github.com/d3/d3.v2.js"></script>
<style>
/* tell the SVG path to be a thin blue line without any area fill */
path {
stroke: steelblue;
stroke-width: 1;
fill: none;