Class: Faye::Server::Socket

Inherits:
Object
  • Object
show all
Defined in:
lib/faye/protocol/socket.rb

Instance Method Summary collapse

Constructor Details

#initialize(server, socket, env) ⇒ Socket

Returns a new instance of Socket.


5
6
7
8
9
# File 'lib/faye/protocol/socket.rb', line 5

def initialize(server, socket, env)
  @server = server
  @socket = socket
  @env    = env
end

Instance Method Details

#closeObject


17
18
19
20
# File 'lib/faye/protocol/socket.rb', line 17

def close
  @socket.close if @socket
  @socket = nil
end

#send(message) ⇒ Object


11
12
13
14
15
# File 'lib/faye/protocol/socket.rb', line 11

def send(message)
  @server.pipe_through_extensions(:outgoing, message, @env) do |piped_message|
    @socket.send(Faye.to_json([piped_message])) if @socket
  end
end