Skip to content

Instantly share code, notes, and snippets.

@pachun
Created April 22, 2013 20:44
Show Gist options
  • Save pachun/5438382 to your computer and use it in GitHub Desktop.
Save pachun/5438382 to your computer and use it in GitHub Desktop.
class Client
attr_accessor :socket, :thread, :connection_time
def initialize(socket)
@socket = socket
@connection_time = Time.now
end
def run
@thread = Thread.start do
client_handshake
end
end
def kill
disconnect
Thread.kill @thread
end
private
def client_handshake
msg = @socket.gets
puts "received:#{msg}"
kill if msg != 'CHAT'
end
def disconnect
@socket.close
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment