class Conreality::Action
A transaction-scoped action.
Attributes
session[R]
The client session this actions belongs to.
@return [Session]
Public Class Methods
new(session)
click to toggle source
@param session [Session]
# File lib/conreality/action.rb, line 15 def initialize(session) @session = session end
Public Instance Methods
inspect()
click to toggle source
Returns a developer-friendly representation of this action.
@return [String]
# File lib/conreality/action.rb, line 23 def inspect sprintf("#<%s:%#0x>", self.class.name, self.__id__) end
send_event(predicate, subject, object = nil)
click to toggle source
@param predicate [String] a predicate string @param subject [Object, UUID] the source object @param object [Object, UUID, nil] the target object, if any @return [Event] the sent event
# File lib/conreality/action.rb, line 34 def send_event(predicate, subject, object = nil) predicate = predicate.to_s subject = (subject.respond_to?(:uuid) ? subject.uuid : subject).to_s object = object ? (object.respond_to?(:uuid) ? object.uuid : object).to_s : nil result = @session.client.call_proc_with_result(:event_send, args: [predicate, subject, object]) result ? Conreality::Event.new(@session, result.to_i) : nil end
send_message(sender, text)
click to toggle source
@param sender [Object, UUID] the sending asset or player @param text [String] the message contents as text @return [Message] the sent message @todo Support for audio messages.
# File lib/conreality/action.rb, line 52 def send_message(sender, text) sender = (sender.respond_to?(:uuid) ? sender.uuid : sender).to_s text = text.to_s result = @session.client.call_proc_with_result(:message_send, args: [sender, text]) result ? Conreality::Message.new(@session, result.to_i) : nil end