Skip to content

Instantly share code, notes, and snippets.

@pedro-ramirez-suarez
Created September 8, 2015 13:55
Show Gist options
  • Save pedro-ramirez-suarez/00c1525f5d19bfe565f1 to your computer and use it in GitHub Desktop.
Save pedro-ramirez-suarez/00c1525f5d19bfe565f1 to your computer and use it in GitHub Desktop.
How to connect with DiPS
//Abrimos la conexión a Dips
client = new DiPS.Client.DiPSClient("ws://localhost:8888/dips");
//Nos subcribimos al evento test
client.Subscribe("test", (m) =>
{
//Imprimimos en la consola la entidad (el objeto m es dynamic)
Console.WriteLine("Name: {0}, age:{1}",m.name, n.age);
});
require 'dipsclient'
#Conectando a DiPS
client = DiPS::DiPSClient.new "ws://localhost:8888/dips"
puts "Conectando"
#esperar a que esté lista la conexión
sleep 2.0
puts "Subscribiendo a evento test"
#Cuando el evento "test" es publicado, se ejecuta este código
client.Subscribe ("test") { |payload| puts "Received from DiPS: #{payload}" }
#este es la entidad que espera el subscriptor
param = {"name"=>"pedro", "age" =>39}
puts "Publishing"
client.Publish "test", param
puts "Enter to exit"
k = gets.chomp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment