Skip to content

Instantly share code, notes, and snippets.

View jiehan1029's full-sized avatar

Jie Han jiehan1029

  • Cultivate AI
  • San Francisco Bay Area
View GitHub Profile
@luciopaiva
luciopaiva / _Full-socketio-client-and-server-example.md
Last active April 27, 2024 04:09
Full socket.io client and server example

Full socket.io client and server example

Last updated: 2021-02-21, tested with socket.io v3.1.1

This is the simplest implementation you will find for a client/server WebSockets architecture using socket.io.

To see a full explanation, read my answer on SO here: https://stackoverflow.com/a/24232050/778272.

If you're looking for examples using frameworks, check these links:

var isDev = false;
if (window.__env.NODE_ENV === 'development') {
isDev = true;
}
if (isDev) {
var MixpanelMock;
MixpanelMock = (function() {
function MixpanelMock() {
this.init = function() {
@creationix
creationix / chatServer.js
Created November 19, 2010 20:47
A simple TCP based chat server written in node.js
// Load the TCP Library
net = require('net');
// Keep track of the chat clients
var clients = [];
// Start a TCP Server
net.createServer(function (socket) {
// Identify this client