federation fixes

This commit is contained in:
Administrator 2025-09-05 17:43:55 -07:00
parent 3f05e092ee
commit 2bfa33874e
2 changed files with 12 additions and 7 deletions

View file

@ -1,6 +1,6 @@
Gem::Specification.new do |s| Gem::Specification.new do |s|
s.name = 'gxg-framework' s.name = 'gxg-framework'
s.version = '0.0.63' s.version = '0.0.64'
s.licenses = ['HIPPOCRATIC 2.1', 'https://firstdonoharm.dev/version/2/1/license.html'] s.licenses = ['HIPPOCRATIC 2.1', 'https://firstdonoharm.dev/version/2/1/license.html']
s.summary = "GxG Framework" s.summary = "GxG Framework"
s.description = "GxG Framework" s.description = "GxG Framework"

View file

@ -16,7 +16,7 @@ module GxG
module Messages module Messages
class Channel class Channel
# #
def initialize(the_uuid) def initialize(the_uuid=nil, the_object=nil)
@uuid = the_uuid @uuid = the_uuid
@inbox = [] @inbox = []
@inbox_safety = ::Mutex.new @inbox_safety = ::Mutex.new
@ -25,6 +25,7 @@ module GxG
@socket = nil @socket = nil
@remote = nil @remote = nil
@channel_secret = nil @channel_secret = nil
@object = the_object
self self
end end
# #
@ -32,6 +33,10 @@ module GxG
@uuid @uuid
end end
# #
def object()
@object
end
#
def socket() def socket()
@socket @socket
end end
@ -148,8 +153,8 @@ module GxG
GXG_FEDERATION_SAFETY.synchronize { GXG_FEDERATION[:connections][(the_uuid)] } GXG_FEDERATION_SAFETY.synchronize { GXG_FEDERATION[:connections][(the_uuid)] }
end end
# #
def create_channel(the_uuid) def create_channel(the_uuid=nil, the_object=nil)
GXG_FEDERATION_SAFETY.synchronize { GXG_FEDERATION[:connections][(the_uuid)] = ::GxG::Messages::Channel.new(the_uuid)} GXG_FEDERATION_SAFETY.synchronize { GXG_FEDERATION[:connections][(the_uuid)] = ::GxG::Messages::Channel.new(the_uuid,the_object)}
end end
# #
def destroy_channel(the_uuid) def destroy_channel(the_uuid)
@ -999,7 +1004,7 @@ class Object
def send_message(the_message) def send_message(the_message)
unless @uuid unless @uuid
@uuid = ::GxG::uuid_generate.to_s.to_sym @uuid = ::GxG::uuid_generate.to_s.to_sym
::GxG::CHANNELS.create_channel(@uuid) ::GxG::CHANNELS.create_channel(@uuid,self)
end end
::GxG::CHANNELS.send_message(@uuid, the_message) ::GxG::CHANNELS.send_message(@uuid, the_message)
true true
@ -1008,7 +1013,7 @@ class Object
def next_message() def next_message()
unless @uuid unless @uuid
@uuid = ::GxG::uuid_generate.to_s.to_sym @uuid = ::GxG::uuid_generate.to_s.to_sym
::GxG::CHANNELS.create_channel(@uuid) ::GxG::CHANNELS.create_channel(@uuid,self)
end end
::GxG::CHANNELS.next_message(@uuid) ::GxG::CHANNELS.next_message(@uuid)
end end
@ -1016,7 +1021,7 @@ class Object
def post(the_message) def post(the_message)
unless @uuid unless @uuid
@uuid = ::GxG::uuid_generate.to_s.to_sym @uuid = ::GxG::uuid_generate.to_s.to_sym
::GxG::CHANNELS.create_channel(@uuid) ::GxG::CHANNELS.create_channel(@uuid,self)
end end
channel = ::GxG::CHANNELS.fetch_channel(@uuid) channel = ::GxG::CHANNELS.fetch_channel(@uuid)
if channel if channel