Giter Site home page Giter Site logo

jamestryand / bellyrub Goto Github PK

View Code? Open in Web Editor NEW

This project forked from continuoustests/bellyrub

0.0 2.0 0.0 1.4 MB

A library for writing cross platform desktop applications using .NET and HTML

License: MIT License

Batchfile 1.45% Shell 1.36% C# 89.34% JavaScript 5.36% HTML 2.48%

bellyrub's Introduction

BellyRub

BellyRub is a library for writing cross platform desktop applications using .NET and HTML. when you start bellyrub it will scan the machine for any known browsers and start it up in application mode for your application. On the .Net side it uses dynamic objects through Json.Net while on the client end you can expect json objects.

Just pull the source code and run deploy.sh/deploy.bat to compile it. You will find the complied library in the ReleaseBinaries folder. If you want to see how it works you can try the BellyRub.TestClient

If you wnat to try writing an application with it create any console/windowed .Net application and put this in your main method

using System;
using System.IO;
using System.Threading;
using System.Reflection;
using BellyRub;
using BellyRub.UI;

namespace MyApplication
{
	class Program
	{
		static void Main(string[] args)
		{
            // Set a path where we keep our html code and create the engine
            // Use a site directory located in the same folder as your executable
            var path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "site");
            var engine = new BellyEngine(path);
            // Set up messaging to talk to your UI code and start the engine
            var browser = engine
                .OnConnected(() => Console.WriteLine("Client connected"))
                .OnDisconnected(() => Console.WriteLine("Client disconnected"))
                .OnSendException((ex) => Console.WriteLine(ex.ToString()))
                .On("hello-server", (m) => Console.WriteLine(m))
                .RespondTo("ping-server", (m, with) => with("pong from server"))
                .Start();

            // Wait for the browser to connect then communicate
            engine.WaitForFirstClientToConnect();
            engine.Send("hello-client", "hello world from server");
            Console.WriteLine(engine.Request("ping-client"));

            // Make the browser the topmost window
            browser.BringToFront(); 

            // Run for as long as the browser is connected
            while (engine.HasConnectedClients) {
                Thread.Sleep(50);
            }
		}
	}
}

Put an index html file in the directory specified in your main method with something like this. If you want the html code to follow the .Net app just add them to the .Net project and choose copy always.

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Expires" content="0" />
	<title>MyApplication</title>

    <script type="text/javascript" src="/js/bellyrub-client.js"></script>

     <script type="text/javascript">
        // Create the bellyrub client
        var client = createBellyRubClient(); 
        console.log('connecting..');
        // When connected communicate a bit
        client.onconnected = function () {
            client.send('hello-server', 'hello world from client');
            client.request('ping-server', '', function (m) { console.log(m); });
        };
        // Setup message handlers
        client.handlers['hello-client'] = function (msg, respondWith) {
            console.log(msg);
        };
        client.handlers['ping-client'] = function (msg, respondWith) {
            respondWith('pong from client');
        }; 
        // Connect to bellyrub engine
        client.connect(); 
    </script>   
</head>
<body>
Hello Bellyrub!
</body>
</html>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.