Go to file
Mike Nolan c3ea0b0766 fixed in mono turns out the problem was in Tesses.WebServer.WebSocket 2023-03-17 23:35:03 -05:00
.github Version Client.js (#255) 2021-05-12 18:48:19 -07:00
.vscode Port to tesses.webserver 2023-03-17 03:08:32 -05:00
Documentation Add HD icon 2019-07-17 16:13:53 -07:00
Example Ported this library to Tesses.WebServer 2023-03-17 03:07:49 -05:00
Ooui fixed in mono turns out the problem was in Tesses.WebServer.WebSocket 2023-03-17 23:35:03 -05:00
Ooui.Forms Port to tesses.webserver 2023-03-17 03:15:07 -05:00
Samples Port to tesses.webserver 2023-03-17 03:08:32 -05:00
Tests Update tests to .NET 5 2021-05-12 17:51:35 -07:00
.editorconfig Update styling 2017-11-09 12:34:08 -08:00
.gitignore Add Ooui.Wasm package 2018-03-13 14:44:35 -07:00
.gitmodules Use https path for mono submodule 2018-07-20 09:09:33 +02:00
LICENSE.md Ported this library to Tesses.WebServer 2023-03-17 03:07:49 -05:00
Ooui.sln Port to tesses.webserver 2023-03-17 03:08:32 -05:00
Ooui_license.txt Port to tesses.webserver 2023-03-17 03:21:00 -05:00
README.md fixed in mono turns out the problem was in Tesses.WebServer.WebSocket 2023-03-17 23:35:03 -05:00
ooui.service Update the service to always restart 2017-12-09 15:50:59 -08:00

README.md

Ooui Web Framework

Version Package Description
NuGet Package Ooui Core library with HTML elements and a server
NuGet Package Ooui.Forms Xamarin.Forms backend using Ooui for Tesses.WebServer (Status)

This is a Tesses.WebServer port of Ooui, this port is GPL3.0 unlike the original

Ooui (pronounced weee!) is a small cross-platform UI library for .NET that uses web technologies.

It presents a classic object-oriented UI API that controls a dumb browser. With Ooui, you get the full power of your favorite .NET programming language plus the ability to interact with your app using any device.

Try it Online

Head on over to http://ooui.mecha.parts to tryout the samples.

You can also load https://s3.amazonaws.com/praeclarum.org/wasm/index.html to try the WebAssembly mode of Ooui running Xamarin.Forms. (That's Xamarin.Forms running right in your browser!)

Try the Samples Locally

git clone https://gitlab.tesses.net/tesses50/Ooui-tws-port.git
cd Ooui-tws-port

dotnet run --project Samples/Samples.csproj

This will open the default starting page for the Samples. Now point your browser at http://localhost:8080/shared-button

You should see a button that tracks the number of times it was clicked. The source code for that button is shown in the example below.

Example App

Here is the complete source code to a fully collaborative button clicking app.

using System;
using Ooui;
using Tesses.WebServer;
class Program
{
    static void Main(string[] args)
    {
        //unlike the original UI is an instance that inherits Tesses.WebServer.Server
        UI Ui = new Ui();
        // Create the UI
        var button = new Button("Click me!");

        // Add some logic to it
        var count = 0;
        button.Click += (s, e) => {
            count++;
            button.Text = $"Clicked {count} times";
        };

        // Publishing makes an object available at a given URL
        // The user should be directed to http://localhost:8080/shared-button
        Ui.Publish ("/shared-button", button);

        //Listen until someone hits CTRL+C
        Ui.StartServer(8080);
    }
}

Make sure to add a reference to Ooui before you start running!

dotnet add package Ooui
dotnet run

With just that code, a web server that serves the HTML and web socket logic necessary for an interactive button will start.

The Many Ways to Ooui

Ooui has been broken up into several packages to increase the variety of ways that it can be used. Here are some combinations to help you decide which way is best for you.

OouiOoui.AspNetCoreOoui.FormsOoui.Wasm
Web DOM with the Built-in Web Server
Web DOM with ASP.NET Core
Xamarin.Forms with ASP.NET Core
Xamarin.Forms with the built-in web server
Web DOM with Web Assembly
Xamarin.Forms with Web Assembly

How it works

When the user requests a page, the page will connect to the server using a web socket. This socket is used to keep the server's in-memory model of the UI (the one you work with as a programmer) in sync with the actual UI shown to the user in their browser. This is done using a simple messaging protocol with JSON packets.

When the user clicks or otherwise interacts with the UI, those events are sent back over the web socket so that your code can deal with them.

In the case of web assembly, this same dataflow takes place. However, sockets are not used as all communication is done locally in the browser process.

Contributing

Ooui is open source and I love merging PRs. Please fork away, and please obey the .editorconfig file. :-) Try to file issues for things that you want to work on before you start the work so that there's no duplicated effort. If you just want to help out, check out the issues and dive in!, please contribute to the original not this port (you can fork this port if you want)

Why I ported this library to Tesses.WebServer

Well so this would work on mono (mono to my knowledge doesn't support System.Net.WebSockets) and I would like to integrate this library into my webserver