Esempio n. 1
0
 private void initialize(string rootPath)
 {
     if (rootPath != null)
     {
         WebServer.RESTBootstrapper.SetRootDir(rootPath);
     }
     _channel = new Messaging.Channel();
     _channel.OnReceive((msg) => {
         if (_handlers.ContainsKey(msg.Subject))
         {
             _handlers[msg.Subject](msg.Body);
         }
         else if (_responders.ContainsKey(msg.Subject))
         {
             var token = msg.Token.ToString();
             var body  = (object)msg.Body;
             _responders[msg.Subject](body, (o) => {
                 Send(token, o);
             });
         }
     });
     RespondTo("belly:get-bellyrub-client-content", (body, respondWith) => {
         var assembly     = Assembly.GetExecutingAssembly();
         var resourceName = "BellyRub.WebServer.site.bellyrub-client.js";
         using (Stream stream = assembly.GetManifestResourceStream(resourceName)) {
             using (StreamReader reader = new StreamReader(stream)) {
                 dynamic o = new ExpandoObject();
                 o.content = reader.ReadToEnd();
                 respondWith(o);
             }
         }
     });
 }
Esempio n. 2
0
 private void initialize(string rootPath)
 {
     if (rootPath != null)
         WebServer.RESTBootstrapper.SetRootDir(rootPath);
     _channel = new Messaging.Channel();
     _channel.OnReceive((msg) =>  {
         if (_handlers.ContainsKey(msg.Subject)) {
             _handlers[msg.Subject](msg.Body);
         } else if (_responders.ContainsKey(msg.Subject)) {
             var token = msg.Token.ToString();
             var body = (object)msg.Body;
             _responders[msg.Subject](body, (o) => {
                 Send(token, o);
             });
         }
     });
     RespondTo("belly:get-bellyrub-client-content", (body, respondWith) => {
         var assembly = Assembly.GetExecutingAssembly();
         var resourceName = "BellyRub.WebServer.site.bellyrub-client.js";
         using (Stream stream = assembly.GetManifestResourceStream(resourceName)) {
             using (StreamReader reader = new StreamReader(stream)) {
                 dynamic o = new ExpandoObject();
                 o.content = reader.ReadToEnd();
                 respondWith(o);
             }
         }
     });
 }