Class: DDP::Server::WebSocket

Inherits:
Celluloid::WebSocket
  • Object
show all
Includes:
Protocol
Defined in:
lib/ddp/server.rb

Overview

Server on top of a Celluloid::WebSocket

Constant Summary

Constants included from Protocol

Protocol::DDP_VERSION

Constants included from Protocol::RPC

Protocol::RPC::NO_RESULT

Instance Attribute Summary collapse

Attributes included from Protocol

#session_id

Instance Method Summary collapse

Methods included from Protocol

#handle_connect, #handle_established, #handle_session, #new_session_id

Methods included from Protocol::RPC

#handle_method, #handle_rpc, #send_error_result, #send_result, #send_updated

Methods included from Protocol::Data

#handle_data, #handle_sub, #handle_unsub, #send_added, #send_added_before, #send_changed, #send_moved_before, #send_nosub, #send_ready, #send_removed, #subscription_update

Methods included from Protocol::Heartbeat

#handle_heartbeat

Constructor Details

#initialize(api_class, *args) ⇒ WebSocket

Returns a new instance of WebSocket.



15
16
17
18
# File 'lib/ddp/server.rb', line 15

def initialize(api_class, *args)
	@api = api_class.new(*args)
	@subscriptions = {}
end

Instance Attribute Details

#apiObject

Returns the value of attribute api.



13
14
15
# File 'lib/ddp/server.rb', line 13

def api
  @api
end

#subscriptionsObject

Returns the value of attribute subscriptions.



13
14
15
# File 'lib/ddp/server.rb', line 13

def subscriptions
  @subscriptions
end

Instance Method Details

#on_openObject



20
21
22
# File 'lib/ddp/server.rb', line 20

def on_open
	handle_connect
end

#read_messageObject



24
25
26
# File 'lib/ddp/server.rb', line 24

def read_message
	EJSON.parse read
end

#write_message(message) ⇒ Object



28
29
30
# File 'lib/ddp/server.rb', line 28

def write_message(message)
	write EJSON.generate(message)
end