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
# coding: utf-8 | |
require "socket" | |
require 'libwebsocket' | |
require 'eventmachine' | |
class WebSocket | |
def initialize(url, params = {}) | |
@hs ||= LibWebSocket::OpeningHandshake::Client.new(:url => url, :version => params[:version]) |
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
# coding: utf-8 | |
require 'eventmachine' | |
module EM | |
module Strand | |
extend self | |
# Fires up EventMachine in a fiber, ready to take orders. | |
# | |
# @return EM::Strand |
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
require 'rubygems' | |
require 'socket' | |
include Socket::Constants | |
class ChatServer | |
def initialize | |
@reading = Array.new | |
@writing = Array.new | |
@clients = Hash.new |
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
# Load the rails application | |
require File.expand_path('../application', __FILE__) | |
# Initialize the rails application | |
Footnotes::Application.initialize! | |
# Start the websocket server | |
Footnotes::WebSocketServer.new(10081) |