Created
February 26, 2013 19:30
-
-
Save kyledrake/5041357 to your computer and use it in GitHub Desktop.
debugging
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
#!/usr/bin/env ruby | |
require 'celluloid/io' | |
require 'json' | |
require 'websocket' | |
class WebsocketClient | |
include Celluloid::IO | |
def initialize(host, port) | |
puts "*** Connecting to echo server on #{host}:#{port}" | |
@socket = TCPSocket.new(host, port) | |
@handshake = WebSocket::Handshake::Client.new(:url => "ws://#{host}:#{port}") | |
@socket.write @handshake.to_s | |
payload = ->(num){ ['test', {name: 'Captain Test', number: num}].to_json } | |
100_000.times {|i| | |
frame = WebSocket::Frame::Outgoing::Server.new(:version => @handshake.version, :data => payload.call(i), :type => :text) | |
@socket.write frame.to_s | |
} | |
end | |
end | |
client = WebsocketClient.new("127.0.0.1", 1234) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment