Ejemplo n.º 1
0
        public static void Start(string url)
        {
            IWampHost host = new DefaultWampHost(url);

            IWampHostedRealm realm = host.RealmContainer.GetRealmByName("realm1");

            var todosController = new TodosController();
            Task<IAsyncDisposable> registrationTask = realm.Services.RegisterCallee(todosController);

            host.Open();
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            // http://autobahn.ws/static/file/autobahnjs.html

            const string location = "ws://localhost:9000/";
            using (IWampHost host = new DefaultWampHost(location))
            {
                host.Open();
                // Use this in order to publish events to subscribers.
                IWampTopicContainer topicContainer = host.TopicContainer;
                Console.WriteLine("Server is running on " + location);
                Console.ReadLine();
            }
        }
Ejemplo n.º 3
0
        public static void Main(string[] args)
        {
            // http://autobahn.ws/static/file/autobahnjs.html

            const string location = "ws://localhost:9000/";
            using (IWampHost host = new DefaultWampHost(location))
            {
                ICalculator instance = new Calculator();
                host.HostService(instance);

                host.Open();

                Console.WriteLine("Server is running on " + location);
                Console.ReadLine();
            }
        }
Ejemplo n.º 4
0
        public static void Main(string[] args)
        {
            const string location = "ws://127.0.0.1:8080/";

            using (IWampHost host = new DefaultWampHost(location))
            {
                IArgumentsService instance = new ArgumentsService();

                IWampHostedRealm realm = host.RealmContainer.GetRealmByName("realm1");

                Task <IAsyncDisposable> registrationTask = realm.Services.RegisterCallee(instance);
                // await registrationTask;
                registrationTask.Wait();

                host.Open();

                Console.WriteLine("Server is running on " + location);
                Console.ReadLine();
            }
        }
Ejemplo n.º 5
0
        private static void RouterCode(string serverAddress, IEnumerable <IWampRpcOperation> operations)
        {
            DefaultWampHost host =
                new DefaultWampHost(serverAddress, new IWampBinding[]
            {
                new JTokenMsgpackBinding(),
                new JTokenJsonBinding(),
            });

            IWampRealm realm = host.RealmContainer.GetRealmByName("realm1");

            foreach (IWampRpcOperation operation in operations)
            {
                realm.RpcCatalog.Register(operation, new RegisterOptions());
            }

            host.Open();
            Console.WriteLine("Server is up");
            Console.ReadLine();
        }
Ejemplo n.º 6
0
        public static void Main(string[] args)
        {
            const string serverAddress = "ws://127.0.0.1:8080/ws";

            DefaultWampHost host = new DefaultWampHost(serverAddress);

            host.Open();

            Console.WriteLine("Press enter after a subscriber subscribes to com.myapp.topic1");

            Console.ReadLine();

            IWampHostedRealm realm = host.RealmContainer.GetRealmByName("realm1");

            ISubject <int> subject =
                realm.Services.GetSubject <int>("com.myapp.topic1");

            int counter = 0;

            IObservable <long> timer =
                Observable.Timer(TimeSpan.FromMilliseconds(0),
                                 TimeSpan.FromMilliseconds(1000));

            IDisposable disposable =
                timer.Subscribe(x =>
            {
                counter++;

                Console.WriteLine("Publishing to topic 'com.myapp.topic1': " + counter);
                try
                {
                    subject.OnNext(counter);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                }
            });

            Console.ReadLine();
        }
Ejemplo n.º 7
0
        public static async Task Start()
        {
            DefaultWampHost host = new DefaultWampHost("ws://127.0.0.1:8080/");

            IWampHostedRealm realm = host.RealmContainer.GetRealmByName("realm1");

            realm.SessionCreated += SessionCreated;
            realm.TopicContainer.TopicCreated += TopicCreated;

            host.Open();

            Func <object, Task <object> > createConnection =
                Edge.Func(@"
            var autobahn = require('autobahn');

            return function (options, cb) {

                var connection = new autobahn.Connection({url: options.url, realm: options.realm});
    
connection.onopen = function (session) {

   // 1) subscribe to a topic
   function onevent(args) {
      console.log(""Event:"", args[0]);
   }
   session.subscribe('com.myapp.hello', onevent);

   // 2) publish an event
   session.publish('com.myapp.hello', ['Hello, world!']);

   // 3) register a procedure for remoting
   function add2(args) {
      return args[0] + args[1];
   }
   session.register('com.myapp.add2', add2);

   // 4) call a remote procedure
   session.call('com.myapp.add2', [2, 3]).then(
      function (res) {
         console.log(""Result:"", res);
      }
   );
};

                connection.open();

                cb(null, connection);
            };
        ");

            dynamic result =
                await createConnection(new
            {
                url   = "ws://localhost:8080/",
                realm = "realm1",
            });

            dynamic result2 =
                await createConnection(new
            {
                url   = "ws://localhost:8080/",
                realm = "realm1",
            });
        }
Ejemplo n.º 8
0
 public PoshSvgEventCaller(DefaultWampHost host)
 {
     FWampHost = host;
 }