codemp/src/server/main.rs

40 lines
800 B
Rust
Raw Normal View History

//! # codemp Server
//!
//! The codemp server itself, in charge of handling the global state, merging operations from
//! all clients and synching everyone's cursor.
//!
pub mod actor;
pub mod events;
pub mod service;
use std::sync::Arc;
use tracing::info;
2022-07-10 19:01:56 +02:00
use tonic::transport::Server;
use crate::{
actor::state::StateManager,
service::{buffer::BufferService, workspace::WorkspaceService},
};
2022-07-10 19:01:56 +02:00
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
tracing_subscriber::fmt::init();
let addr = "[::1]:50051".parse()?;
let state = Arc::new(StateManager::new());
info!("Starting server");
2022-07-10 19:01:56 +02:00
Server::builder()
.add_service(WorkspaceService::new(state.clone()).server())
.add_service(BufferService::new(state.clone()).server())
.serve(addr)
.await?;
2022-07-10 19:01:56 +02:00
Ok(())
2022-07-10 19:01:56 +02:00
}