Class: NetworkChannel

Inherits:
AbstractChannel show all
Defined in:
lib/cirrocumulus/channels.rb

Overview

Communication channel over network.

Instance Method Summary collapse

Constructor Details

#initialize(client, remote_jid) ⇒ NetworkChannel

Returns a new instance of NetworkChannel.



85
86
87
88
89
# File 'lib/cirrocumulus/channels.rb', line 85

def initialize(client, remote_jid)
  @remote_jid = remote_jid
  @client = client
  @serializer = Sexpistol.new
end

Instance Method Details

#agree(sender, action, options = {}) ⇒ Object



107
108
109
# File 'lib/cirrocumulus/channels.rb', line 107

def agree(sender, action, options = {})
  client.queue(serializer.to_sexp(build_message(remote_jid, :agree, action, options)))
end

#failure(sender, action, reason, options = {}) ⇒ Object



115
116
117
# File 'lib/cirrocumulus/channels.rb', line 115

def failure(sender, action, reason, options = {})
  client.queue(serializer.to_sexp(build_message(remote_jid, :failure, [action, reason], options)))
end

#inform(sender, proposition, options = {}) ⇒ Object



91
92
93
# File 'lib/cirrocumulus/channels.rb', line 91

def inform(sender, proposition, options = {})
  client.queue(serializer.to_sexp(build_message(remote_jid, :inform, proposition, options)))
end

#query(sender, expression, options = {}) ⇒ Object



99
100
101
# File 'lib/cirrocumulus/channels.rb', line 99

def query(sender, expression, options = {})
  client.queue(serializer.to_sexp(build_message(remote_jid, :query, expression, options)))
end

#query_if(sender, proposition, options = {}) ⇒ Object



103
104
105
# File 'lib/cirrocumulus/channels.rb', line 103

def query_if(sender, proposition, options = {})
  client.queue(serializer.to_sexp(build_message(remote_jid, :query_if, proposition, options)))
end

#refuse(sender, action, reason, options = {}) ⇒ Object



111
112
113
# File 'lib/cirrocumulus/channels.rb', line 111

def refuse(sender, action, reason, options = {})
  client.queue(serializer.to_sexp(build_message(remote_jid, :refuse, [action, reason], options)))
end

#request(sender, action, options = {}) ⇒ Object



95
96
97
# File 'lib/cirrocumulus/channels.rb', line 95

def request(sender, action, options = {})
  client.queue(serializer.to_sexp(build_message(remote_jid, :request, action, options)))
end