mirror of
https://github.com/mistergibson/gxg-web-client.git
synced 2026-08-15 03:26:00 -07:00
misc. fixes -- messaging
This commit is contained in:
parent
c1b8397275
commit
2f6cf12ddd
3 changed files with 21 additions and 2 deletions
|
|
@ -1152,6 +1152,21 @@ module GxG
|
||||||
GxG::CONNECTION.push(the_message)
|
GxG::CONNECTION.push(the_message)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
# Normally encrypts socket traffic
|
||||||
|
# Send format: channel.socket.send({ :payload => the_message.export.to_s.encrypt(channel.secret).encode64 }.to_json.encode64, :text)
|
||||||
|
::GxG::SOCKET_MONITOR.on(:payload) do |the_data|
|
||||||
|
the_message = ::GxG::Events::Message::import(the_data.to_s.decode64.decrypt(@csrf))
|
||||||
|
if the_message.is_a?(::GxG::Events::Message)
|
||||||
|
the_channel = ::GxG::CHANNELS.fetch_channel(the_message[:to])
|
||||||
|
unless the_channel
|
||||||
|
::GxG::CHANNELS.create_channel(the_message[:to])
|
||||||
|
the_channel = ::GxG::CHANNELS.fetch_channel(the_message[:to])
|
||||||
|
end
|
||||||
|
if the_channel
|
||||||
|
the_channel.write(the_message)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
::GxG::DISPATCHER.add_periodic_timer({:interval => 0.333}) do
|
::GxG::DISPATCHER.add_periodic_timer({:interval => 0.333}) do
|
||||||
::GxG::SOCKET_MONITOR.follow_up
|
::GxG::SOCKET_MONITOR.follow_up
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -33,8 +33,11 @@ module GxG
|
||||||
channel = self.fetch_channel(destination.to_s.to_sym)
|
channel = self.fetch_channel(destination.to_s.to_sym)
|
||||||
if channel
|
if channel
|
||||||
channel.write(the_message)
|
channel.write(the_message)
|
||||||
result = true
|
else
|
||||||
|
# Send format: channel.socket.send({ :payload => the_message.export.to_s.encrypt(channel.secret).encode64 }.to_json.encode64, :text)
|
||||||
|
socket.send({ :payload => the_message.export.to_s.encrypt(connector.secret).encode64 }.to_json.encode64, :text)
|
||||||
end
|
end
|
||||||
|
result = true
|
||||||
end
|
end
|
||||||
# email address -- TODO
|
# email address -- TODO
|
||||||
end
|
end
|
||||||
|
|
@ -100,7 +103,7 @@ module GxG
|
||||||
unless args[0].is_a?(::Hash)
|
unless args[0].is_a?(::Hash)
|
||||||
raise ArgumentError, "you must pass a Hash to create the message"
|
raise ArgumentError, "you must pass a Hash to create the message"
|
||||||
end
|
end
|
||||||
@data = {:sender => nil, :id => (::GxG.uuid_generate().to_s.to_sym), :subject => args[1], :body => nil, :on_success => nil, :on_fail => nil}.merge(args[0])
|
@data = {:sender => nil. :id => GxG::uuid_generate().to_s.to_sym, :subject => args[1], :body => nil, :on_success => nil, :on_fail => nil}.merge(args[0])
|
||||||
unless @data[:sender]
|
unless @data[:sender]
|
||||||
raise ArgumentError, "you must set the :sender key in the argument Hash"
|
raise ArgumentError, "you must set the :sender key in the argument Hash"
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
source /etc/profile
|
source /etc/profile
|
||||||
rm ./gxg.js
|
rm ./gxg.js
|
||||||
|
#opal -I ./gxg -I ./gxg/deps -I ./gxg/standard --compile gxg_web.rb > gxg.js
|
||||||
opal -I ./gxg -I ./gxg/deps -I ./gxg/standard --compile gxg_web.rb > gxg.js
|
opal -I ./gxg -I ./gxg/deps -I ./gxg/standard --compile gxg_web.rb > gxg.js
|
||||||
# minify ./gxg.js > ../src/main/gxg.js
|
# minify ./gxg.js > ../src/main/gxg.js
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue