A port for the SimpleX Chat client API for Ruby
This project is licensed under the GNU AGPL-3.0 (no later versions).
Read LICENSE
for more information.
-
Install the Gem from RubyGems
gem install simplex-chat
-
Start your local simplex-chat client on port 5225 (or any port you wish)
simplex-chat -p 5225
-
Connect the
SimpleXChat::ClientAgent
to your local clientrequire 'simplex-chat' require 'net/http' client = SimpleXChat::ClientAgent.new URI('ws://localhost:5225')
-
Now the client is connected and you can start using the APIs
# Get version version = client.api_version puts "SimpleX Chat version: #{version}" # Listen to incoming client messages loop do chat_msg = client.next_chat_message break if chat_msg == nil # Reply if user sends '/say_hello' if chat_msg[:msg_text] == "/say_hello" client.api_send_text_message chat_msg[:chat_type], chat_msg[:sender], "Hello! This was sent automagically" end end # Much more... Read the examples for more information