Project

sps_duplex

0.0
No commit activity in last 3 years
No release in over 3 years
A gem to allow 2 way communication using a SimplePubSub broker.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 0.5, >= 0.5.5
~> 0.3, >= 0.3.7
 Project Readme

Introducing the sps_duplex gem

The sps_duplex gem allows 2 way communication using the SimplePubSub broker.

Example

Running the SimplePubSub broker

require 'simplepubsub'

SimplePubSub::Broker.start port: '55000'

Running a communications monitor

The communications monitor shows what messages are being published to the messaging broker.

require 'sps-sub'

sps = SPSSub.new host: '127.0.0.1', port: '55000'

sps.subscribe(topic: '#') do |msg, topic|
  puts "%s: %s " % [topic, msg]
end

Running node 2

require 'sps_duplex'

chan = SPSDuplex.new host: '127.0.0.1', port: 55000

Running node 1

require 'sps_duplex'

chan = SPSDuplex.new host: '127.0.0.1', port: 55000, sub_topic: 'node2', pub_topic: 'node1'

Sending a message from node 2

chan.send 'hello'

Observed (from node 1):

node2: hello

Sending a message from node 1

chan.send 'hello2'

Observed (from node 2):

node1: hello2

Observing messages published

From the communications monitor screen the following output was observed:

Connected
chan1/node2: hello 
chan1/node1: hello2 

Resources

chat communication messaging sps gem sps_duplex spsduplex