mirror of
https://github.com/mistergibson/gxg-framework.git
synced 2026-08-15 03:46:00 -07:00
more fedi tweaks
This commit is contained in:
parent
2218358c2f
commit
3f05e092ee
3 changed files with 50 additions and 6 deletions
|
|
@ -411,15 +411,25 @@ unless load_error
|
|||
end
|
||||
#
|
||||
def new_message(*args)
|
||||
if this.actor?()
|
||||
::GxG::Events::Message.new({:sender => this().to_uri(), :subject => args[1], :body => args[0]})
|
||||
else
|
||||
::GxG::Events::Message.new({:sender => this(), :subject => args[1], :body => args[0]})
|
||||
unless @uuid
|
||||
@uuid = ::GxG::uuid_generate.to_s.to_sym
|
||||
::GxG::CHANNELS.create_channel(@uuid)
|
||||
end
|
||||
::GxG::Events::Message.new({:sender => @uuid, :subject => args[1], :body => args[0]})
|
||||
end
|
||||
#
|
||||
public
|
||||
#
|
||||
def defederate()
|
||||
if @uuid
|
||||
the_channel = ::GxG::CHANNELS.fetch_channel(@uuid)
|
||||
if the_channel
|
||||
::GxG::CHANNELS.destroy_channel(@uuid)
|
||||
end
|
||||
end
|
||||
true
|
||||
end
|
||||
#
|
||||
def millisecond_latency(*args,&block)
|
||||
if block
|
||||
starting = Time.now.to_f
|
||||
|
|
|
|||
|
|
@ -3,6 +3,15 @@ module GxG
|
|||
#
|
||||
GXG_FEDERATION = {:title => "Untitled", :uuid => nil, :available => {}, :connections => {}}
|
||||
GXG_FEDERATION_SAFETY = Mutex.new
|
||||
def self.federation_servers()
|
||||
result = {}
|
||||
::GxG::GXG_FEDERATION_SAFETY.synchronize {
|
||||
::GxG::GXG_FEDERATION[:available].each_pair do |uuid, server|
|
||||
result[(uuid.to_s.to_sym)] = server
|
||||
end
|
||||
}
|
||||
result
|
||||
end
|
||||
#
|
||||
module Messages
|
||||
class Channel
|
||||
|
|
@ -112,11 +121,26 @@ module GxG
|
|||
channel.write(the_message)
|
||||
end
|
||||
result = true
|
||||
else
|
||||
end
|
||||
else
|
||||
if ::GxG::valud_uuid?(destination.to_s)
|
||||
# TODO: search available federated servers for channel. ???
|
||||
::GxG::federation_servers.each_pair do |the_uuid, the_server|
|
||||
if the_server.call_event(:federation, {:channel_exist => (destination)})[:result]
|
||||
the_server.call_event(:federation, {:operation => {:forward_message => (the_message.serialize)}})
|
||||
result = true
|
||||
break
|
||||
end
|
||||
end
|
||||
else
|
||||
#
|
||||
# email address -- TODO: integrate sendmail functionality in pure ruby. ::GxG::Networking::SmtpClient.new(::URI::parse("smtp://username:password@hostname.org:587"), {:use_ssl => true, :ignore_ssl_errors => true})
|
||||
#
|
||||
end
|
||||
end
|
||||
#
|
||||
end
|
||||
result
|
||||
end
|
||||
#
|
||||
|
|
@ -997,7 +1021,9 @@ class Object
|
|||
channel = ::GxG::CHANNELS.fetch_channel(@uuid)
|
||||
if channel
|
||||
channel.write(the_message)
|
||||
end
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -3938,6 +3938,14 @@ module GxG
|
|||
result
|
||||
end
|
||||
#
|
||||
def respond_to_event?(service, operation)
|
||||
@clients[(service)].respond_to_event?(operation)
|
||||
end
|
||||
#
|
||||
def call_event(service, operation_frame)
|
||||
@clients[(service)].get(operation_frame)
|
||||
end
|
||||
#
|
||||
def login(username=nil, password=nil)
|
||||
#
|
||||
@services.keys.each do |service|
|
||||
|
|
|
|||
Loading…
Reference in a new issue