Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View bricecarpentier's full-sized avatar

Brice Carpentier bricecarpentier

View GitHub Profile
function maybe(fn) {
try {
return fn();
} catch(error) {
if (error instanceof TypeError) {
return undefined;
}
throw error;
}
}
@bricecarpentier
bricecarpentier / websocket-nodejs-redis-server.js
Last active March 29, 2021 21:12
This is a simple websocket server coded using nodejs and http://einaros.github.io/ws/ connecting to a redis pubsub channel and sending messages to selected clients
var ws = require('ws'),
nconf = require('nconf'),
redis = require('redis');
nconf.argv()
.env();
var server = new ws.Server({port: nconf.get('PORT')});
var sockets = {};
@bricecarpentier
bricecarpentier / as3websocketclient.as
Last active December 17, 2015 11:09
This is a simple websocket client using https://github.com/Worlize/AS3WebSocket
package
{
import flash.display.Sprite;
import com.worlize.websocket.WebSocket;
import com.worlize.websocket.WebSocketEvent;
import com.worlize.websocket.WebSocketErrorEvent;
public class Main extends Sprite