#webrtc #server #web #decentralized #http

simbol-server

Simple Web and WebSocket server, specially for sites that use Simbol

2 stable releases

1.1.0 Aug 29, 2018
1.0.0 Aug 21, 2018

#24 in WebSocket

Download history 25/week @ 2018-08-25 33/week @ 2018-09-01 13/week @ 2018-09-08 6/week @ 2018-09-15 2/week @ 2018-09-22 7/week @ 2018-09-29 1/week @ 2018-10-06 1/week @ 2018-10-13 28/week @ 2018-10-20 4/week @ 2018-10-27

16 downloads per month

MIT license

11KB
217 lines

Simbol server

A simple HTTP and WebSocket server built on top of Iron and ws. Easily get started with a Simbol app

Quick start

In the root directory of you web project, create a server directory for the Rust server:

mkdir server
mkdir server/src
cd server

Create a Cargo.toml and add the dependency to it:

[dependencies]
simbol-server = "1.0.0"

Create a main.rs file in the server/src directory with the following content:

extern crate simbol;

use std::thread;
use simbol::server::*;
use simbol::multivp::*;

fn main() {
    let mut routes: Vec<Route> = Vec::new();
    routes.push(Route {
            mount_path: String::from("/build/"), // Mount path, referring to which part of the URL it takes care of
            relative_path: String::from("build"), // The actual relative path to the content from your project's root directory
    });
    routes.push(Route {
        mount_path: String::from("/assets/"),
        relative_path: String::from("assets"),
    });
    let server = SimbolServer::new(String::from("../"), 3000, routes);
    let http_handle = thread::spawn(move || {
        server.run_server();
    });

    let multivp_server = MultiVP::new(String::from("localhost"), 8091);
    let ws_handle = thread::spawn(move || {
        multivp_server.run_server();
    });

    http_handle.join().unwrap();
    ws_handle.join().unwrap();
}

This will create and run an HTTP server with the default roots to load:

  • index.html from /index.html
  • The different files in /*
  • Your assets, such as GLTF files, from /assets/
  • Your built files, such as your JS and CSS, from /build/

It will also create and run a WebSocket server for the multiVP (social) component of Simbol

Then run it:

cargo run

Contributing

Check out the Contribution guide! If you have any questions, join our community

License

This program is free software and is distributed under an MIT License.

Dependencies

~10MB
~244K SLoC