Browse Source

Merge branch 'main' of https://github.com/KeyKoder/cards-simulator into main

new_protocol
KeyKoder 5 years ago
parent
commit
88d2c10e43
  1. 42
      protobuf/game.proto
  2. 37
      server/src/db.rs
  3. 2
      server/src/games/run.rs
  4. 122
      server/src/grpc.rs
  5. 155
      server/src/grpc/game.rs
  6. 58
      server/src/logger/color_message.rs
  7. 3
      server/src/setup.sql
  8. 20
      unity/Assets/Scripts/Client.cs
  9. 0
      unity/Assets/Scripts/Editor/BuildProtos.cs
  10. 2
      unity/Assets/Scripts/Editor/BuildProtos.cs.meta
  11. 11
      unity/Assets/Scripts/MainMenuController.cs
  12. 299
      unity/Assets/Scripts/grpc/Game.cs
  13. 97
      unity/Assets/Scripts/grpc/GameGrpc.cs

42
protobuf/game.proto

@ -2,41 +2,43 @@ syntax = "proto3";
package game; package game;
// TODO Reorganize this file
// Connection utilities to get a client_id // Connection utilities to get a client_id
service Connection { service Connection {
rpc name(Null) returns(Name); rpc name(Null) returns(Name);
rpc connect(Name) returns(UserID); rpc connect(Name) returns(UserID);
rpc joinLobbyWithCode(LobbyCode) returns(Null); rpc joinLobbyWithCode(LobbyCode) returns(Null);
rpc joinLobbyWithoutCode(Null) returns(LobbyCode); rpc createLobby(LobbyConfig) returns(LobbyCode);
rpc getGames(Null) returns(stream Game);
rpc getPublicLobbies (Null) returns (stream LobbyCode);
} }
// Lobby functionality (client_id required for most of them) // Lobby functionality (client_id required for most of them)
service Lobby { service Lobby {
rpc getGames(Null) returns(stream Game); rpc getCardImage(CardID) returns(Image);
rpc getCardImage(CardID) returns (Image);
rpc vote(Vote) returns(Null); rpc vote(Vote) returns(Null);
rpc ready (Null) returns (Null); rpc ready(Null) returns(Null);
rpc status (Null) returns (LobbyStatus); rpc status(Null) returns(LobbyStatus);
} }
message UserID { message UserID { string id = 1; }
string id = 1;
}
message Name { message Name { string name = 1; }
string name = 1;
message LobbyConfig {
bool public = 1;
// repeated uint32 allowed_games = 2;
} }
message Null {} message Null {}
message CardID { message CardID {
uint64 gameId = 1; uint32 gameId = 1;
string cardId = 2; string cardId = 2;
} }
message Image { message Image { bytes content = 1; }
bytes content = 1;
}
message LobbyCode { uint32 code = 1; } message LobbyCode { uint32 code = 1; }
@ -44,18 +46,18 @@ message Game {
string name = 1; string name = 1;
string version = 2; string version = 2;
repeated string authors = 3; repeated string authors = 3;
uint64 id = 4; uint32 id = 4;
} }
message Vote { uint64 id = 1; } message Vote { uint64 id = 1; }
message LobbyStatus { message LobbyStatus {
repeated Vote votes = 1; repeated Vote votes = 1;
repeated Player ready = 2; repeated Player ready = 2;
bool isStarting = 3; bool isStarting = 3;
} }
message Player { message Player {
string name = 1; string name = 1;
uint64 id = 2; uint32 id = 2;
} }

37
server/src/db.rs

@ -1,5 +1,8 @@
use sqlx::{pool::PoolConnection, prelude::*, query_unchecked, query_as, query_file_unchecked, SqliteConnection, SqlitePool}; use sqlx::{
use tokio::stream::StreamExt; pool::PoolConnection, prelude::*, query_as, query_file_unchecked, query_unchecked, FromRow,
SqliteConnection, SqlitePool,
};
// use tokio::stream::StreamExt;
pub mod types; pub mod types;
@ -39,8 +42,7 @@ pub struct DbConnection {
use uuid::Uuid; use uuid::Uuid;
// FIXME: return Results intead of crashing
// TODO: return Results intead of crashing
impl DbConnection { impl DbConnection {
fn new(conn: PoolConnection<SqliteConnection>) -> Self { fn new(conn: PoolConnection<SqliteConnection>) -> Self {
Self { conn } Self { conn }
@ -60,19 +62,20 @@ impl DbConnection {
uuid uuid
} }
pub async fn users(&mut self) -> Vec<types::User> { // pub async fn users(&mut self) -> Vec<types::User> {
query_as::<_, types::User>("SELECT UUID, Name FROM Users") // query_as::<_, types::User>("SELECT UUID, Name FROM Users")
.fetch_all(&mut self.conn) // .fetch_all(&mut self.conn)
.await // .await
.unwrap() // .unwrap()
} // }
pub async fn create_lobby(&mut self) -> u32 { pub async fn create_lobby(&mut self, public: bool) -> u32 {
let id = rand::random(); let id = rand::random();
self.conn self.conn
.execute(query_unchecked!( .execute(query_unchecked!(
"INSERT INTO Lobbies(id) VALUES(?)", "INSERT INTO Lobbies(id, public) VALUES(?, ?)",
id as i32 id as i32,
public
)) ))
.await .await
.unwrap(); // Server crashes if ids collide .unwrap(); // Server crashes if ids collide
@ -93,5 +96,11 @@ impl DbConnection {
pub async fn close(self) { pub async fn close(self) {
self.conn.close().await.unwrap(); self.conn.close().await.unwrap();
} }
}
pub async fn getPublicLobbies(&mut self) -> Vec<u32> {
query_as::<_, (i32,)>("SELECT ID FROM Lobbies WHERE Public = TRUE")
.fetch_all(&mut self.conn)
.await
.unwrap().into_iter().map(|(x,)| x as u32).collect()
}
}

2
server/src/games/run.rs

@ -25,7 +25,9 @@ struct Setup {
} }
pub struct RunningGame { pub struct RunningGame {
#[allow(unused)] // TODO remove
piles: HashMap<String, Pile>, piles: HashMap<String, Pile>,
#[allow(unused)] // TODO remove
player_piles: Vec<HashMap<String, Pile>>, player_piles: Vec<HashMap<String, Pile>>,
} }

122
server/src/grpc.rs

@ -4,17 +4,19 @@ use log::info;
use std::sync::Arc; use std::sync::Arc;
#[allow(non_camel_case_types)]
mod game; mod game;
use game::connection_server::{Connection, ConnectionServer}; use game::connection_server::{Connection, ConnectionServer};
use game::lobby_server::{Lobby, LobbyServer}; use game::lobby_server::{Lobby, LobbyServer};
use game::{LobbyCode, Null, UserId, Name, CardId, Image}; use game::{CardId, LobbyCode, Image, LobbyConfig, Name, Null, UserId};
use crate::db; use crate::db;
pub struct ConnectionService { pub struct ConnectionService {
conn: Arc<db::DbPool>, conn: Arc<db::DbPool>,
properties: Arc<crate::server_properties::ServerProperties> properties: Arc<crate::server_properties::ServerProperties>,
games: Arc<Vec<crate::games::Game>>,
} }
#[tonic::async_trait] #[tonic::async_trait]
@ -36,39 +38,71 @@ impl Connection for ConnectionService {
) -> Result<Response<Null>, Status> { ) -> Result<Response<Null>, Status> {
let uuid = client_id::get(request.metadata()).map_err(|x| match x { let uuid = client_id::get(request.metadata()).map_err(|x| match x {
client_id::Error::NotSet => Status::failed_precondition("client_id must be set"), client_id::Error::NotSet => Status::failed_precondition("client_id must be set"),
client_id::Error::MalformedUuid => Status::failed_precondition("malformed client_id") client_id::Error::MalformedUuid => Status::failed_precondition("malformed client_id"),
})?; })?;
let lobby = request.get_ref().code; let lobby = request.get_ref().code;
let mut conn = self.conn.acquire().await; let mut conn = self.conn.acquire().await;
conn.join_lobby(uuid, lobby).await; conn.join_lobby(uuid, lobby).await;
conn.close().await; conn.close().await;
Ok(Response::new(Null{})) Ok(Response::new(Null {}))
} }
async fn join_lobby_without_code( async fn create_lobby(
&self, &self,
request: Request<Null>, request: Request<LobbyConfig>,
) -> Result<Response<LobbyCode>, Status> { ) -> Result<Response<LobbyCode>, Status> {
let uuid = client_id::get(request.metadata()).map_err(|x| match x { let uuid = client_id::get(request.metadata()).map_err(|x| match x {
client_id::Error::NotSet => Status::failed_precondition("client_id must be set"), client_id::Error::NotSet => Status::failed_precondition("client_id must be set"),
client_id::Error::MalformedUuid => Status::failed_precondition("malformed client_id") client_id::Error::MalformedUuid => Status::failed_precondition("malformed client_id"),
})?; })?;
let mut conn = self.conn.acquire().await; let mut conn = self.conn.acquire().await;
let lobby = conn.create_lobby().await; let lobby = conn.create_lobby(request.into_inner().public).await;
conn.join_lobby(uuid, lobby).await; conn.join_lobby(uuid, lobby).await;
conn.close().await; conn.close().await;
Ok(Response::new(LobbyCode{code: lobby})) Ok(Response::new(LobbyCode { code: lobby }))
}
async fn name(&self, _request: Request<Null>) -> Result<Response<game::Name>, Status> {
Ok(Response::new(game::Name {
name: self.properties.name.clone(),
}))
}
type getGamesStream = mpsc::UnboundedReceiver<Result<game::Game, tonic::Status>>;
async fn get_games(&self, _: Request<Null>) -> Result<Response<Self::getGamesStream>, Status> {
let (sender, receiver) = mpsc::unbounded_channel();
for (id, game) in self.games.iter().enumerate() {
sender
.send(Ok(game::Game {
id: id as u32,
name: game.name.clone(),
version: game.version.clone(),
authors: game.authors.clone(),
}))
.unwrap();
}
Ok(Response::new(receiver))
} }
async fn name( type getPublicLobbiesStream = mpsc::UnboundedReceiver<Result<LobbyCode, tonic::Status>>;
async fn get_public_lobbies(
&self, &self,
_request: Request<Null>, _request: Request<Null>,
) -> Result<Response<game::Name>, Status> { ) -> Result<Response<Self::getPublicLobbiesStream>, Status> {
Ok(Response::new(game::Name {name: self.properties.name.clone() })) let (sender, receiver) = mpsc::unbounded_channel();
let mut conn = self.conn.acquire().await;
for id in conn.getPublicLobbies().await {
sender
.send(Ok(LobbyCode{code: id}))
.unwrap();
}
conn.close();
Ok(Response::new(receiver))
} }
} }
use tokio::sync::mpsc; use tokio::sync::mpsc;
pub struct LobbyService { pub struct LobbyService {
@ -78,55 +112,51 @@ pub struct LobbyService {
#[tonic::async_trait] #[tonic::async_trait]
impl Lobby for LobbyService { impl Lobby for LobbyService {
type getGamesStream = mpsc::UnboundedReceiver<Result<game::Game, tonic::Status>>; async fn get_card_image(
&self,
async fn get_games( request: tonic::Request<CardId>,
&self, ) -> Result<tonic::Response<Image>, tonic::Status> {
_: Request<Null>,
) -> Result<Response<Self::getGamesStream>, Status> {
let (sender, receiver) = mpsc::unbounded_channel();
for (id, game) in self.games.iter().enumerate() {
sender.send(Ok(game::Game {id: id as u64, name: game.name.clone(), version: game.version.clone(), authors: game.authors.clone()})).unwrap();
}
Ok(Response::new(receiver))
}
async fn get_card_image(&self, request: tonic::Request<CardId>) -> Result<tonic::Response<Image>, tonic::Status> {
let id = request.into_inner(); let id = request.into_inner();
let game = &self.games.as_ref()[id.game_id as usize]; let game = &self.games.as_ref()[id.game_id as usize];
let card = game.get_card_path(&id.card_id); let card = game.get_card_path(&id.card_id);
let mut buffer = Vec::new(); let mut buffer = Vec::new();
image::open(&card).expect(&format!("Error loading the image in {:?}", card)).write_to(&mut buffer, image::ImageOutputFormat::Png).unwrap(); image::open(&card)
Ok(Response::new(Image {content: buffer})) .expect(&format!("Error loading the image in {:?}", card))
.write_to(&mut buffer, image::ImageOutputFormat::Png)
.unwrap();
Ok(Response::new(Image { content: buffer }))
} }
async fn vote( async fn vote(&self, _request: Request<game::Vote>) -> Result<Response<Null>, Status> {
&self,
request: Request<game::Vote>,
) -> Result<Response<Null>, Status> {
todo!() todo!()
} }
async fn ready( async fn ready(&self, _request: Request<Null>) -> Result<Response<Null>, Status> {
&self,
request: Request<Null>,
) -> Result<Response<Null>, Status> {
todo!() todo!()
} }
async fn status( async fn status(&self, _request: Request<Null>) -> Result<Response<game::LobbyStatus>, Status> {
&self,
request: Request<Null>,
) -> Result<Response<game::LobbyStatus>, Status> {
todo!() todo!()
} }
} }
pub async fn start(pool: db::DbPool, games: Vec<crate::games::Game>, properties: crate::server_properties::ServerProperties) { pub async fn start(
pool: db::DbPool,
games: Vec<crate::games::Game>,
properties: crate::server_properties::ServerProperties,
) {
let arc = Arc::new(pool); let arc = Arc::new(pool);
let properties = Arc::new(properties); let properties = Arc::new(properties);
let connection = ConnectionService { conn: arc.clone(), properties }; let games = Arc::new(games);
let lobby = LobbyService {conn: arc.clone(), games: Arc::new(games)}; let connection = ConnectionService {
conn: arc.clone(),
properties,
games: games.clone(),
};
let lobby = LobbyService {
conn: arc.clone(),
games,
};
Server::builder() Server::builder()
.add_service(ConnectionServer::new(connection)) .add_service(ConnectionServer::new(connection))
@ -137,9 +167,7 @@ pub async fn start(pool: db::DbPool, games: Vec<crate::games::Game>, properties:
} }
mod client_id { mod client_id {
pub fn get( pub fn get(metadata: &tonic::metadata::MetadataMap) -> Result<uuid::Uuid, Error> {
metadata: &tonic::metadata::MetadataMap,
) -> Result<uuid::Uuid, Error> {
metadata metadata
.get("client_id") .get("client_id")
.ok_or(Error::NotSet) .ok_or(Error::NotSet)

155
server/src/grpc/game.rs

@ -9,11 +9,17 @@ pub struct Name {
pub name: std::string::String, pub name: std::string::String,
} }
#[derive(Clone, PartialEq, ::prost::Message)] #[derive(Clone, PartialEq, ::prost::Message)]
pub struct LobbyConfig {
/// repeated uint32 allowed_games = 2;
#[prost(bool, tag = "1")]
pub public: bool,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Null {} pub struct Null {}
#[derive(Clone, PartialEq, ::prost::Message)] #[derive(Clone, PartialEq, ::prost::Message)]
pub struct CardId { pub struct CardId {
#[prost(uint64, tag = "1")] #[prost(uint32, tag = "1")]
pub game_id: u64, pub game_id: u32,
#[prost(string, tag = "2")] #[prost(string, tag = "2")]
pub card_id: std::string::String, pub card_id: std::string::String,
} }
@ -35,8 +41,8 @@ pub struct Game {
pub version: std::string::String, pub version: std::string::String,
#[prost(string, repeated, tag = "3")] #[prost(string, repeated, tag = "3")]
pub authors: ::std::vec::Vec<std::string::String>, pub authors: ::std::vec::Vec<std::string::String>,
#[prost(uint64, tag = "4")] #[prost(uint32, tag = "4")]
pub id: u64, pub id: u32,
} }
#[derive(Clone, PartialEq, ::prost::Message)] #[derive(Clone, PartialEq, ::prost::Message)]
pub struct Vote { pub struct Vote {
@ -56,8 +62,8 @@ pub struct LobbyStatus {
pub struct Player { pub struct Player {
#[prost(string, tag = "1")] #[prost(string, tag = "1")]
pub name: std::string::String, pub name: std::string::String,
#[prost(uint64, tag = "2")] #[prost(uint32, tag = "2")]
pub id: u64, pub id: u32,
} }
#[doc = r" Generated server implementations."] #[doc = r" Generated server implementations."]
pub mod connection_server { pub mod connection_server {
@ -78,10 +84,28 @@ pub mod connection_server {
&self, &self,
request: tonic::Request<super::LobbyCode>, request: tonic::Request<super::LobbyCode>,
) -> Result<tonic::Response<super::Null>, tonic::Status>; ) -> Result<tonic::Response<super::Null>, tonic::Status>;
async fn join_lobby_without_code( async fn create_lobby(
&self, &self,
request: tonic::Request<super::Null>, request: tonic::Request<super::LobbyConfig>,
) -> Result<tonic::Response<super::LobbyCode>, tonic::Status>; ) -> Result<tonic::Response<super::LobbyCode>, tonic::Status>;
#[doc = "Server streaming response type for the getGames method."]
type getGamesStream: Stream<Item = Result<super::Game, tonic::Status>>
+ Send
+ Sync
+ 'static;
async fn get_games(
&self,
request: tonic::Request<super::Null>,
) -> Result<tonic::Response<Self::getGamesStream>, tonic::Status>;
#[doc = "Server streaming response type for the getPublicLobbies method."]
type getPublicLobbiesStream: Stream<Item = Result<super::LobbyCode, tonic::Status>>
+ Send
+ Sync
+ 'static;
async fn get_public_lobbies(
&self,
request: tonic::Request<super::Null>,
) -> Result<tonic::Response<Self::getPublicLobbiesStream>, tonic::Status>;
} }
#[doc = " Connection utilities to get a client_id"] #[doc = " Connection utilities to get a client_id"]
#[derive(Debug)] #[derive(Debug)]
@ -203,16 +227,18 @@ pub mod connection_server {
}; };
Box::pin(fut) Box::pin(fut)
} }
"/game.Connection/joinLobbyWithoutCode" => { "/game.Connection/createLobby" => {
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
struct joinLobbyWithoutCodeSvc<T: Connection>(pub Arc<T>); struct createLobbySvc<T: Connection>(pub Arc<T>);
impl<T: Connection> tonic::server::UnaryService<super::Null> for joinLobbyWithoutCodeSvc<T> { impl<T: Connection> tonic::server::UnaryService<super::LobbyConfig> for createLobbySvc<T> {
type Response = super::LobbyCode; type Response = super::LobbyCode;
type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>; type Future = BoxFuture<tonic::Response<Self::Response>, tonic::Status>;
fn call(&mut self, request: tonic::Request<super::Null>) -> Self::Future { fn call(
&mut self,
request: tonic::Request<super::LobbyConfig>,
) -> Self::Future {
let inner = self.0.clone(); let inner = self.0.clone();
let fut = let fut = async move { (*inner).create_lobby(request).await };
async move { (*inner).join_lobby_without_code(request).await };
Box::pin(fut) Box::pin(fut)
} }
} }
@ -220,7 +246,7 @@ pub mod connection_server {
let fut = async move { let fut = async move {
let interceptor = inner.1.clone(); let interceptor = inner.1.clone();
let inner = inner.0; let inner = inner.0;
let method = joinLobbyWithoutCodeSvc(inner); let method = createLobbySvc(inner);
let codec = tonic::codec::ProstCodec::default(); let codec = tonic::codec::ProstCodec::default();
let mut grpc = if let Some(interceptor) = interceptor { let mut grpc = if let Some(interceptor) = interceptor {
tonic::server::Grpc::with_interceptor(codec, interceptor) tonic::server::Grpc::with_interceptor(codec, interceptor)
@ -232,6 +258,66 @@ pub mod connection_server {
}; };
Box::pin(fut) Box::pin(fut)
} }
"/game.Connection/getGames" => {
#[allow(non_camel_case_types)]
struct getGamesSvc<T: Connection>(pub Arc<T>);
impl<T: Connection> tonic::server::ServerStreamingService<super::Null> for getGamesSvc<T> {
type Response = super::Game;
type ResponseStream = T::getGamesStream;
type Future =
BoxFuture<tonic::Response<Self::ResponseStream>, tonic::Status>;
fn call(&mut self, request: tonic::Request<super::Null>) -> Self::Future {
let inner = self.0.clone();
let fut = async move { (*inner).get_games(request).await };
Box::pin(fut)
}
}
let inner = self.inner.clone();
let fut = async move {
let interceptor = inner.1;
let inner = inner.0;
let method = getGamesSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = if let Some(interceptor) = interceptor {
tonic::server::Grpc::with_interceptor(codec, interceptor)
} else {
tonic::server::Grpc::new(codec)
};
let res = grpc.server_streaming(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/game.Connection/getPublicLobbies" => {
#[allow(non_camel_case_types)]
struct getPublicLobbiesSvc<T: Connection>(pub Arc<T>);
impl<T: Connection> tonic::server::ServerStreamingService<super::Null> for getPublicLobbiesSvc<T> {
type Response = super::LobbyCode;
type ResponseStream = T::getPublicLobbiesStream;
type Future =
BoxFuture<tonic::Response<Self::ResponseStream>, tonic::Status>;
fn call(&mut self, request: tonic::Request<super::Null>) -> Self::Future {
let inner = self.0.clone();
let fut = async move { (*inner).get_public_lobbies(request).await };
Box::pin(fut)
}
}
let inner = self.inner.clone();
let fut = async move {
let interceptor = inner.1;
let inner = inner.0;
let method = getPublicLobbiesSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = if let Some(interceptor) = interceptor {
tonic::server::Grpc::with_interceptor(codec, interceptor)
} else {
tonic::server::Grpc::new(codec)
};
let res = grpc.server_streaming(method, req).await;
Ok(res)
};
Box::pin(fut)
}
_ => Box::pin(async move { _ => Box::pin(async move {
Ok(http::Response::builder() Ok(http::Response::builder()
.status(200) .status(200)
@ -269,15 +355,6 @@ pub mod lobby_server {
#[doc = "Generated trait containing gRPC methods that should be implemented for use with LobbyServer."] #[doc = "Generated trait containing gRPC methods that should be implemented for use with LobbyServer."]
#[async_trait] #[async_trait]
pub trait Lobby: Send + Sync + 'static { pub trait Lobby: Send + Sync + 'static {
#[doc = "Server streaming response type for the getGames method."]
type getGamesStream: Stream<Item = Result<super::Game, tonic::Status>>
+ Send
+ Sync
+ 'static;
async fn get_games(
&self,
request: tonic::Request<super::Null>,
) -> Result<tonic::Response<Self::getGamesStream>, tonic::Status>;
async fn get_card_image( async fn get_card_image(
&self, &self,
request: tonic::Request<super::CardId>, request: tonic::Request<super::CardId>,
@ -328,36 +405,6 @@ pub mod lobby_server {
fn call(&mut self, req: http::Request<B>) -> Self::Future { fn call(&mut self, req: http::Request<B>) -> Self::Future {
let inner = self.inner.clone(); let inner = self.inner.clone();
match req.uri().path() { match req.uri().path() {
"/game.Lobby/getGames" => {
#[allow(non_camel_case_types)]
struct getGamesSvc<T: Lobby>(pub Arc<T>);
impl<T: Lobby> tonic::server::ServerStreamingService<super::Null> for getGamesSvc<T> {
type Response = super::Game;
type ResponseStream = T::getGamesStream;
type Future =
BoxFuture<tonic::Response<Self::ResponseStream>, tonic::Status>;
fn call(&mut self, request: tonic::Request<super::Null>) -> Self::Future {
let inner = self.0.clone();
let fut = async move { (*inner).get_games(request).await };
Box::pin(fut)
}
}
let inner = self.inner.clone();
let fut = async move {
let interceptor = inner.1;
let inner = inner.0;
let method = getGamesSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = if let Some(interceptor) = interceptor {
tonic::server::Grpc::with_interceptor(codec, interceptor)
} else {
tonic::server::Grpc::new(codec)
};
let res = grpc.server_streaming(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/game.Lobby/getCardImage" => { "/game.Lobby/getCardImage" => {
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
struct getCardImageSvc<T: Lobby>(pub Arc<T>); struct getCardImageSvc<T: Lobby>(pub Arc<T>);

58
server/src/logger/color_message.rs

@ -1,36 +1,34 @@
use crossterm::{ use crossterm::{queue, style::Print};
cursor::{MoveRight, MoveToNextLine},
event::{Event, KeyCode, KeyModifiers, MouseEvent},
queue,
style::{Print, PrintStyledContent},
};
use std::io::Write; use std::io::Write;
pub fn print_line(message: &String, use_colors: bool, stdout: &mut std::io::Stdout) { pub fn print_line(message: &String, use_colors: bool, stdout: &mut std::io::Stdout) {
if use_colors { if use_colors {
let mut s = String::new(); let mut s = String::new();
let mut highlight = false; let mut highlight = false;
for c in message.chars() { for c in message.chars() {
if c == '`' {
if c == '`' { // queue!(stdout, Print(format!("{}`", highlight))).unwrap();
// queue!(stdout, Print(format!("{}`", highlight))).unwrap(); if highlight {
if highlight { let styled = format!(
let styled = format!("\x1B[{}m{}\x1B[0m", fern::colors::Color::Blue.to_fg_str(), s); "\x1B[{}m{}\x1B[0m",
queue!(stdout, Print(styled)).unwrap(); fern::colors::Color::Blue.to_fg_str(),
s = String::new(); s
}else{ );
queue!(stdout, Print(s)).unwrap(); queue!(stdout, Print(styled)).unwrap();
s = String::new(); s = String::new();
} } else {
highlight = !highlight; queue!(stdout, Print(s)).unwrap();
continue; s = String::new();
} }
highlight = !highlight;
continue;
}
s.push(c); s.push(c);
} }
queue!(stdout, Print(&s)).unwrap(); queue!(stdout, Print(&s)).unwrap();
}else { } else {
queue!(stdout, Print(message)).unwrap(); queue!(stdout, Print(message)).unwrap();
} }
} }

3
server/src/setup.sql

@ -11,7 +11,8 @@ CREATE TABLE Users (
); );
CREATE TABLE Lobbies ( CREATE TABLE Lobbies (
ID INT NOT NULL UNIQUE PRIMARY KEY ID INT NOT NULL UNIQUE PRIMARY KEY,
Public BOOLEAN DEFAULT false
); );
CREATE TABLE UsersInLobbies ( CREATE TABLE UsersInLobbies (

20
unity/Assets/Scripts/Client.cs

@ -50,9 +50,9 @@ public static class Client
connection.joinLobbyWithCode(new Game.LobbyCode { Code = (uint)lobby }, new Metadata { new Metadata.Entry("client_id", connId) }); connection.joinLobbyWithCode(new Game.LobbyCode { Code = (uint)lobby }, new Metadata { new Metadata.Entry("client_id", connId) });
} }
public string CreateLobby() public string CreateLobby(bool isPublic)
{ {
lobby = connection.joinLobbyWithoutCode(new Game.Null(), new Metadata { new Metadata.Entry("client_id", connId) }).Code; lobby = connection.createLobby(new Game.LobbyConfig {Public = isPublic}, new Metadata { new Metadata.Entry("client_id", connId) }).Code;
return Base32.ToString((uint)lobby); return Base32.ToString((uint)lobby);
} }
@ -68,9 +68,23 @@ public static class Client
} }
} }
public List<string> getPublicLobbies() {
AsyncServerStreamingCall<Game.LobbyCode> stream = connection.getPublicLobbies(new Game.Null());
List<string> l = new List<string>();
while (runSync(stream.ResponseStream.MoveNext()))
{
Game.LobbyCode g = stream.ResponseStream.Current;
l.Add(Base32.ToString(g.Code));
// Debug.Log("Received " + feature.ToString());
}
// Debug.Log(stream.ResponseStream.Current);
return l;
}
public List<Game.Game> getGames() public List<Game.Game> getGames()
{ {
AsyncServerStreamingCall<Game.Game> stream = lobby_client.getGames(new Game.Null()); AsyncServerStreamingCall<Game.Game> stream = connection.getGames(new Game.Null());
List<Game.Game> l = new List<Game.Game>(); List<Game.Game> l = new List<Game.Game>();
while (runSync(stream.ResponseStream.MoveNext())) while (runSync(stream.ResponseStream.MoveNext()))

0
unity/Assets/EditorScripts/BuildProtos.cs → unity/Assets/Scripts/Editor/BuildProtos.cs

2
unity/Assets/EditorScripts/BuildProtos.cs.meta → unity/Assets/Scripts/Editor/BuildProtos.cs.meta

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: d503170ae4972ff3db5f76af29a9d5d0 guid: b147307868234ce40afbc5ba5dc4a020
MonoImporter: MonoImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2

11
unity/Assets/Scripts/MainMenuController.cs

@ -121,7 +121,7 @@ public class MainMenuController : MonoBehaviour {
if (conn != null) { if (conn != null) {
var lobby = conn.GetLobby(); var lobby = conn.GetLobby();
if (lobby == null) { if (lobby == null) {
lobby = conn.CreateLobby(); lobby = conn.CreateLobby(true);
mainMenu.SetActive(false); mainMenu.SetActive(false);
serverMenu.SetActive(false); serverMenu.SetActive(false);
lobbyMenu.SetActive(true); lobbyMenu.SetActive(true);
@ -151,6 +151,13 @@ public class MainMenuController : MonoBehaviour {
DestroyImmediate(serverScroll.transform.GetChild(i).gameObject); DestroyImmediate(serverScroll.transform.GetChild(i).gameObject);
} }
// Simulate Lobbies in a Server // Simulate Lobbies in a Server
var conn = Client.GetConnection();
if(conn != null) {
foreach(string lobby in conn.getPublicLobbies()) {
Debug.Log(lobby);
}
// conn.Close();
}
for (int i = 0; i < Random.Range(2, 15); i++) { for (int i = 0; i < Random.Range(2, 15); i++) {
var lobby = Instantiate(serverScroll.transform.GetChild(0), serverScroll.transform); var lobby = Instantiate(serverScroll.transform.GetChild(0), serverScroll.transform);
lobby.GetComponentInChildren<Text>().text = "LBY" + Random.Range(0, 10) + Random.Range(0, 10) + Random.Range(0, 10); lobby.GetComponentInChildren<Text>().text = "LBY" + Random.Range(0, 10) + Random.Range(0, 10) + Random.Range(0, 10);
@ -174,7 +181,9 @@ public class MainMenuController : MonoBehaviour {
gameGO.GetComponentsInChildren<Text>()[2].text = string.Join(", ", game.Authors); gameGO.GetComponentsInChildren<Text>()[2].text = string.Join(", ", game.Authors);
gameGO.gameObject.SetActive(true); gameGO.gameObject.SetActive(true);
} }
// conn.Close();
} }
lobbyMenu.GetComponentInChildren<Scrollable>().Reload(); lobbyMenu.GetComponentInChildren<Scrollable>().Reload();
} }
} }

299
unity/Assets/Scripts/grpc/Game.cs

@ -25,28 +25,30 @@ namespace Game {
byte[] descriptorData = global::System.Convert.FromBase64String( byte[] descriptorData = global::System.Convert.FromBase64String(
string.Concat( string.Concat(
"CgpnYW1lLnByb3RvEgRnYW1lIhQKBlVzZXJJRBIKCgJpZBgBIAEoCSIUCgRO", "CgpnYW1lLnByb3RvEgRnYW1lIhQKBlVzZXJJRBIKCgJpZBgBIAEoCSIUCgRO",
"YW1lEgwKBG5hbWUYASABKAkiBgoETnVsbCIoCgZDYXJkSUQSDgoGZ2FtZUlk", "YW1lEgwKBG5hbWUYASABKAkiHQoLTG9iYnlDb25maWcSDgoGcHVibGljGAEg",
"GAEgASgEEg4KBmNhcmRJZBgCIAEoCSIYCgVJbWFnZRIPCgdjb250ZW50GAEg", "ASgIIgYKBE51bGwiKAoGQ2FyZElEEg4KBmdhbWVJZBgBIAEoDRIOCgZjYXJk",
"ASgMIhkKCUxvYmJ5Q29kZRIMCgRjb2RlGAEgASgNIkIKBEdhbWUSDAoEbmFt", "SWQYAiABKAkiGAoFSW1hZ2USDwoHY29udGVudBgBIAEoDCIZCglMb2JieUNv",
"ZRgBIAEoCRIPCgd2ZXJzaW9uGAIgASgJEg8KB2F1dGhvcnMYAyADKAkSCgoC", "ZGUSDAoEY29kZRgBIAEoDSJCCgRHYW1lEgwKBG5hbWUYASABKAkSDwoHdmVy",
"aWQYBCABKAQiEgoEVm90ZRIKCgJpZBgBIAEoBCJZCgtMb2JieVN0YXR1cxIZ", "c2lvbhgCIAEoCRIPCgdhdXRob3JzGAMgAygJEgoKAmlkGAQgASgNIhIKBFZv",
"CgV2b3RlcxgBIAMoCzIKLmdhbWUuVm90ZRIbCgVyZWFkeRgCIAMoCzIMLmdh", "dGUSCgoCaWQYASABKAQiWQoLTG9iYnlTdGF0dXMSGQoFdm90ZXMYASADKAsy",
"bWUuUGxheWVyEhIKCmlzU3RhcnRpbmcYAyABKAgiIgoGUGxheWVyEgwKBG5h", "Ci5nYW1lLlZvdGUSGwoFcmVhZHkYAiADKAsyDC5nYW1lLlBsYXllchISCgpp",
"bWUYASABKAkSCgoCaWQYAiABKAQyuAEKCkNvbm5lY3Rpb24SHgoEbmFtZRIK", "c1N0YXJ0aW5nGAMgASgIIiIKBlBsYXllchIMCgRuYW1lGAEgASgJEgoKAmlk",
"LmdhbWUuTnVsbBoKLmdhbWUuTmFtZRIjCgdjb25uZWN0EgouZ2FtZS5OYW1l", "GAIgASgNMo8CCgpDb25uZWN0aW9uEh4KBG5hbWUSCi5nYW1lLk51bGwaCi5n",
"GgwuZ2FtZS5Vc2VySUQSMAoRam9pbkxvYmJ5V2l0aENvZGUSDy5nYW1lLkxv", "YW1lLk5hbWUSIwoHY29ubmVjdBIKLmdhbWUuTmFtZRoMLmdhbWUuVXNlcklE",
"YmJ5Q29kZRoKLmdhbWUuTnVsbBIzChRqb2luTG9iYnlXaXRob3V0Q29kZRIK", "EjAKEWpvaW5Mb2JieVdpdGhDb2RlEg8uZ2FtZS5Mb2JieUNvZGUaCi5nYW1l",
"LmdhbWUuTnVsbBoPLmdhbWUuTG9iYnlDb2RlMsIBCgVMb2JieRIkCghnZXRH", "Lk51bGwSMQoLY3JlYXRlTG9iYnkSES5nYW1lLkxvYmJ5Q29uZmlnGg8uZ2Ft",
"YW1lcxIKLmdhbWUuTnVsbBoKLmdhbWUuR2FtZTABEikKDGdldENhcmRJbWFn", "ZS5Mb2JieUNvZGUSJAoIZ2V0R2FtZXMSCi5nYW1lLk51bGwaCi5nYW1lLkdh",
"ZRIMLmdhbWUuQ2FyZElEGgsuZ2FtZS5JbWFnZRIeCgR2b3RlEgouZ2FtZS5W", "bWUwARIxChBnZXRQdWJsaWNMb2JiaWVzEgouZ2FtZS5OdWxsGg8uZ2FtZS5M",
"b3RlGgouZ2FtZS5OdWxsEh8KBXJlYWR5EgouZ2FtZS5OdWxsGgouZ2FtZS5O", "b2JieUNvZGUwATKcAQoFTG9iYnkSKQoMZ2V0Q2FyZEltYWdlEgwuZ2FtZS5D",
"dWxsEicKBnN0YXR1cxIKLmdhbWUuTnVsbBoRLmdhbWUuTG9iYnlTdGF0dXNi", "YXJkSUQaCy5nYW1lLkltYWdlEh4KBHZvdGUSCi5nYW1lLlZvdGUaCi5nYW1l",
"BnByb3RvMw==")); "Lk51bGwSHwoFcmVhZHkSCi5nYW1lLk51bGwaCi5nYW1lLk51bGwSJwoGc3Rh",
"dHVzEgouZ2FtZS5OdWxsGhEuZ2FtZS5Mb2JieVN0YXR1c2IGcHJvdG8z"));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { }, new pbr::FileDescriptor[] { },
new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] {
new pbr::GeneratedClrTypeInfo(typeof(global::Game.UserID), global::Game.UserID.Parser, new[]{ "Id" }, null, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Game.UserID), global::Game.UserID.Parser, new[]{ "Id" }, null, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Game.Name), global::Game.Name.Parser, new[]{ "Name_" }, null, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Game.Name), global::Game.Name.Parser, new[]{ "Name_" }, null, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Game.LobbyConfig), global::Game.LobbyConfig.Parser, new[]{ "Public" }, null, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Game.Null), global::Game.Null.Parser, null, null, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Game.Null), global::Game.Null.Parser, null, null, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Game.CardID), global::Game.CardID.Parser, new[]{ "GameId", "CardId" }, null, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Game.CardID), global::Game.CardID.Parser, new[]{ "GameId", "CardId" }, null, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Game.Image), global::Game.Image.Parser, new[]{ "Content" }, null, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Game.Image), global::Game.Image.Parser, new[]{ "Content" }, null, null, null, null),
@ -405,6 +407,181 @@ namespace Game {
} }
public sealed partial class LobbyConfig : pb::IMessage<LobbyConfig>
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
, pb::IBufferMessage
#endif
{
private static readonly pb::MessageParser<LobbyConfig> _parser = new pb::MessageParser<LobbyConfig>(() => new LobbyConfig());
private pb::UnknownFieldSet _unknownFields;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pb::MessageParser<LobbyConfig> Parser { get { return _parser; } }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pbr::MessageDescriptor Descriptor {
get { return global::Game.GameReflection.Descriptor.MessageTypes[2]; }
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
pbr::MessageDescriptor pb::IMessage.Descriptor {
get { return Descriptor; }
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public LobbyConfig() {
OnConstruction();
}
partial void OnConstruction();
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public LobbyConfig(LobbyConfig other) : this() {
public_ = other.public_;
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public LobbyConfig Clone() {
return new LobbyConfig(this);
}
/// <summary>Field number for the "public" field.</summary>
public const int PublicFieldNumber = 1;
private bool public_;
/// <summary>
/// repeated uint32 allowed_games = 2;
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public bool Public {
get { return public_; }
set {
public_ = value;
}
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override bool Equals(object other) {
return Equals(other as LobbyConfig);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public bool Equals(LobbyConfig other) {
if (ReferenceEquals(other, null)) {
return false;
}
if (ReferenceEquals(other, this)) {
return true;
}
if (Public != other.Public) return false;
return Equals(_unknownFields, other._unknownFields);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override int GetHashCode() {
int hash = 1;
if (Public != false) hash ^= Public.GetHashCode();
if (_unknownFields != null) {
hash ^= _unknownFields.GetHashCode();
}
return hash;
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override string ToString() {
return pb::JsonFormatter.ToDiagnosticString(this);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void WriteTo(pb::CodedOutputStream output) {
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
output.WriteRawMessage(this);
#else
if (Public != false) {
output.WriteRawTag(8);
output.WriteBool(Public);
}
if (_unknownFields != null) {
_unknownFields.WriteTo(output);
}
#endif
}
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) {
if (Public != false) {
output.WriteRawTag(8);
output.WriteBool(Public);
}
if (_unknownFields != null) {
_unknownFields.WriteTo(ref output);
}
}
#endif
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int CalculateSize() {
int size = 0;
if (Public != false) {
size += 1 + 1;
}
if (_unknownFields != null) {
size += _unknownFields.CalculateSize();
}
return size;
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void MergeFrom(LobbyConfig other) {
if (other == null) {
return;
}
if (other.Public != false) {
Public = other.Public;
}
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void MergeFrom(pb::CodedInputStream input) {
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
input.ReadRawMessage(this);
#else
uint tag;
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 8: {
Public = input.ReadBool();
break;
}
}
}
#endif
}
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) {
uint tag;
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input);
break;
case 8: {
Public = input.ReadBool();
break;
}
}
}
}
#endif
}
public sealed partial class Null : pb::IMessage<Null> public sealed partial class Null : pb::IMessage<Null>
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
, pb::IBufferMessage , pb::IBufferMessage
@ -417,7 +594,7 @@ namespace Game {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pbr::MessageDescriptor Descriptor { public static pbr::MessageDescriptor Descriptor {
get { return global::Game.GameReflection.Descriptor.MessageTypes[2]; } get { return global::Game.GameReflection.Descriptor.MessageTypes[3]; }
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@ -553,7 +730,7 @@ namespace Game {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pbr::MessageDescriptor Descriptor { public static pbr::MessageDescriptor Descriptor {
get { return global::Game.GameReflection.Descriptor.MessageTypes[3]; } get { return global::Game.GameReflection.Descriptor.MessageTypes[4]; }
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@ -582,9 +759,9 @@ namespace Game {
/// <summary>Field number for the "gameId" field.</summary> /// <summary>Field number for the "gameId" field.</summary>
public const int GameIdFieldNumber = 1; public const int GameIdFieldNumber = 1;
private ulong gameId_; private uint gameId_;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public ulong GameId { public uint GameId {
get { return gameId_; } get { return gameId_; }
set { set {
gameId_ = value; gameId_ = value;
@ -623,7 +800,7 @@ namespace Game {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override int GetHashCode() { public override int GetHashCode() {
int hash = 1; int hash = 1;
if (GameId != 0UL) hash ^= GameId.GetHashCode(); if (GameId != 0) hash ^= GameId.GetHashCode();
if (CardId.Length != 0) hash ^= CardId.GetHashCode(); if (CardId.Length != 0) hash ^= CardId.GetHashCode();
if (_unknownFields != null) { if (_unknownFields != null) {
hash ^= _unknownFields.GetHashCode(); hash ^= _unknownFields.GetHashCode();
@ -641,9 +818,9 @@ namespace Game {
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
output.WriteRawMessage(this); output.WriteRawMessage(this);
#else #else
if (GameId != 0UL) { if (GameId != 0) {
output.WriteRawTag(8); output.WriteRawTag(8);
output.WriteUInt64(GameId); output.WriteUInt32(GameId);
} }
if (CardId.Length != 0) { if (CardId.Length != 0) {
output.WriteRawTag(18); output.WriteRawTag(18);
@ -658,9 +835,9 @@ namespace Game {
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) {
if (GameId != 0UL) { if (GameId != 0) {
output.WriteRawTag(8); output.WriteRawTag(8);
output.WriteUInt64(GameId); output.WriteUInt32(GameId);
} }
if (CardId.Length != 0) { if (CardId.Length != 0) {
output.WriteRawTag(18); output.WriteRawTag(18);
@ -675,8 +852,8 @@ namespace Game {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int CalculateSize() { public int CalculateSize() {
int size = 0; int size = 0;
if (GameId != 0UL) { if (GameId != 0) {
size += 1 + pb::CodedOutputStream.ComputeUInt64Size(GameId); size += 1 + pb::CodedOutputStream.ComputeUInt32Size(GameId);
} }
if (CardId.Length != 0) { if (CardId.Length != 0) {
size += 1 + pb::CodedOutputStream.ComputeStringSize(CardId); size += 1 + pb::CodedOutputStream.ComputeStringSize(CardId);
@ -692,7 +869,7 @@ namespace Game {
if (other == null) { if (other == null) {
return; return;
} }
if (other.GameId != 0UL) { if (other.GameId != 0) {
GameId = other.GameId; GameId = other.GameId;
} }
if (other.CardId.Length != 0) { if (other.CardId.Length != 0) {
@ -713,7 +890,7 @@ namespace Game {
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break; break;
case 8: { case 8: {
GameId = input.ReadUInt64(); GameId = input.ReadUInt32();
break; break;
} }
case 18: { case 18: {
@ -735,7 +912,7 @@ namespace Game {
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input);
break; break;
case 8: { case 8: {
GameId = input.ReadUInt64(); GameId = input.ReadUInt32();
break; break;
} }
case 18: { case 18: {
@ -761,7 +938,7 @@ namespace Game {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pbr::MessageDescriptor Descriptor { public static pbr::MessageDescriptor Descriptor {
get { return global::Game.GameReflection.Descriptor.MessageTypes[4]; } get { return global::Game.GameReflection.Descriptor.MessageTypes[5]; }
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@ -933,7 +1110,7 @@ namespace Game {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pbr::MessageDescriptor Descriptor { public static pbr::MessageDescriptor Descriptor {
get { return global::Game.GameReflection.Descriptor.MessageTypes[5]; } get { return global::Game.GameReflection.Descriptor.MessageTypes[6]; }
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@ -1105,7 +1282,7 @@ namespace Game {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pbr::MessageDescriptor Descriptor { public static pbr::MessageDescriptor Descriptor {
get { return global::Game.GameReflection.Descriptor.MessageTypes[6]; } get { return global::Game.GameReflection.Descriptor.MessageTypes[7]; }
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@ -1168,9 +1345,9 @@ namespace Game {
/// <summary>Field number for the "id" field.</summary> /// <summary>Field number for the "id" field.</summary>
public const int IdFieldNumber = 4; public const int IdFieldNumber = 4;
private ulong id_; private uint id_;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public ulong Id { public uint Id {
get { return id_; } get { return id_; }
set { set {
id_ = value; id_ = value;
@ -1203,7 +1380,7 @@ namespace Game {
if (Name.Length != 0) hash ^= Name.GetHashCode(); if (Name.Length != 0) hash ^= Name.GetHashCode();
if (Version.Length != 0) hash ^= Version.GetHashCode(); if (Version.Length != 0) hash ^= Version.GetHashCode();
hash ^= authors_.GetHashCode(); hash ^= authors_.GetHashCode();
if (Id != 0UL) hash ^= Id.GetHashCode(); if (Id != 0) hash ^= Id.GetHashCode();
if (_unknownFields != null) { if (_unknownFields != null) {
hash ^= _unknownFields.GetHashCode(); hash ^= _unknownFields.GetHashCode();
} }
@ -1229,9 +1406,9 @@ namespace Game {
output.WriteString(Version); output.WriteString(Version);
} }
authors_.WriteTo(output, _repeated_authors_codec); authors_.WriteTo(output, _repeated_authors_codec);
if (Id != 0UL) { if (Id != 0) {
output.WriteRawTag(32); output.WriteRawTag(32);
output.WriteUInt64(Id); output.WriteUInt32(Id);
} }
if (_unknownFields != null) { if (_unknownFields != null) {
_unknownFields.WriteTo(output); _unknownFields.WriteTo(output);
@ -1251,9 +1428,9 @@ namespace Game {
output.WriteString(Version); output.WriteString(Version);
} }
authors_.WriteTo(ref output, _repeated_authors_codec); authors_.WriteTo(ref output, _repeated_authors_codec);
if (Id != 0UL) { if (Id != 0) {
output.WriteRawTag(32); output.WriteRawTag(32);
output.WriteUInt64(Id); output.WriteUInt32(Id);
} }
if (_unknownFields != null) { if (_unknownFields != null) {
_unknownFields.WriteTo(ref output); _unknownFields.WriteTo(ref output);
@ -1271,8 +1448,8 @@ namespace Game {
size += 1 + pb::CodedOutputStream.ComputeStringSize(Version); size += 1 + pb::CodedOutputStream.ComputeStringSize(Version);
} }
size += authors_.CalculateSize(_repeated_authors_codec); size += authors_.CalculateSize(_repeated_authors_codec);
if (Id != 0UL) { if (Id != 0) {
size += 1 + pb::CodedOutputStream.ComputeUInt64Size(Id); size += 1 + pb::CodedOutputStream.ComputeUInt32Size(Id);
} }
if (_unknownFields != null) { if (_unknownFields != null) {
size += _unknownFields.CalculateSize(); size += _unknownFields.CalculateSize();
@ -1292,7 +1469,7 @@ namespace Game {
Version = other.Version; Version = other.Version;
} }
authors_.Add(other.authors_); authors_.Add(other.authors_);
if (other.Id != 0UL) { if (other.Id != 0) {
Id = other.Id; Id = other.Id;
} }
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
@ -1322,7 +1499,7 @@ namespace Game {
break; break;
} }
case 32: { case 32: {
Id = input.ReadUInt64(); Id = input.ReadUInt32();
break; break;
} }
} }
@ -1352,7 +1529,7 @@ namespace Game {
break; break;
} }
case 32: { case 32: {
Id = input.ReadUInt64(); Id = input.ReadUInt32();
break; break;
} }
} }
@ -1374,7 +1551,7 @@ namespace Game {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pbr::MessageDescriptor Descriptor { public static pbr::MessageDescriptor Descriptor {
get { return global::Game.GameReflection.Descriptor.MessageTypes[7]; } get { return global::Game.GameReflection.Descriptor.MessageTypes[8]; }
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@ -1546,7 +1723,7 @@ namespace Game {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pbr::MessageDescriptor Descriptor { public static pbr::MessageDescriptor Descriptor {
get { return global::Game.GameReflection.Descriptor.MessageTypes[8]; } get { return global::Game.GameReflection.Descriptor.MessageTypes[9]; }
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@ -1768,7 +1945,7 @@ namespace Game {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pbr::MessageDescriptor Descriptor { public static pbr::MessageDescriptor Descriptor {
get { return global::Game.GameReflection.Descriptor.MessageTypes[9]; } get { return global::Game.GameReflection.Descriptor.MessageTypes[10]; }
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@ -1808,9 +1985,9 @@ namespace Game {
/// <summary>Field number for the "id" field.</summary> /// <summary>Field number for the "id" field.</summary>
public const int IdFieldNumber = 2; public const int IdFieldNumber = 2;
private ulong id_; private uint id_;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public ulong Id { public uint Id {
get { return id_; } get { return id_; }
set { set {
id_ = value; id_ = value;
@ -1839,7 +2016,7 @@ namespace Game {
public override int GetHashCode() { public override int GetHashCode() {
int hash = 1; int hash = 1;
if (Name.Length != 0) hash ^= Name.GetHashCode(); if (Name.Length != 0) hash ^= Name.GetHashCode();
if (Id != 0UL) hash ^= Id.GetHashCode(); if (Id != 0) hash ^= Id.GetHashCode();
if (_unknownFields != null) { if (_unknownFields != null) {
hash ^= _unknownFields.GetHashCode(); hash ^= _unknownFields.GetHashCode();
} }
@ -1860,9 +2037,9 @@ namespace Game {
output.WriteRawTag(10); output.WriteRawTag(10);
output.WriteString(Name); output.WriteString(Name);
} }
if (Id != 0UL) { if (Id != 0) {
output.WriteRawTag(16); output.WriteRawTag(16);
output.WriteUInt64(Id); output.WriteUInt32(Id);
} }
if (_unknownFields != null) { if (_unknownFields != null) {
_unknownFields.WriteTo(output); _unknownFields.WriteTo(output);
@ -1877,9 +2054,9 @@ namespace Game {
output.WriteRawTag(10); output.WriteRawTag(10);
output.WriteString(Name); output.WriteString(Name);
} }
if (Id != 0UL) { if (Id != 0) {
output.WriteRawTag(16); output.WriteRawTag(16);
output.WriteUInt64(Id); output.WriteUInt32(Id);
} }
if (_unknownFields != null) { if (_unknownFields != null) {
_unknownFields.WriteTo(ref output); _unknownFields.WriteTo(ref output);
@ -1893,8 +2070,8 @@ namespace Game {
if (Name.Length != 0) { if (Name.Length != 0) {
size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); size += 1 + pb::CodedOutputStream.ComputeStringSize(Name);
} }
if (Id != 0UL) { if (Id != 0) {
size += 1 + pb::CodedOutputStream.ComputeUInt64Size(Id); size += 1 + pb::CodedOutputStream.ComputeUInt32Size(Id);
} }
if (_unknownFields != null) { if (_unknownFields != null) {
size += _unknownFields.CalculateSize(); size += _unknownFields.CalculateSize();
@ -1910,7 +2087,7 @@ namespace Game {
if (other.Name.Length != 0) { if (other.Name.Length != 0) {
Name = other.Name; Name = other.Name;
} }
if (other.Id != 0UL) { if (other.Id != 0) {
Id = other.Id; Id = other.Id;
} }
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
@ -1932,7 +2109,7 @@ namespace Game {
break; break;
} }
case 16: { case 16: {
Id = input.ReadUInt64(); Id = input.ReadUInt32();
break; break;
} }
} }
@ -1954,7 +2131,7 @@ namespace Game {
break; break;
} }
case 16: { case 16: {
Id = input.ReadUInt64(); Id = input.ReadUInt32();
break; break;
} }
} }

97
unity/Assets/Scripts/grpc/GameGrpc.cs

@ -49,6 +49,8 @@ namespace Game {
static readonly grpc::Marshaller<global::Game.Name> __Marshaller_game_Name = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Game.Name.Parser)); static readonly grpc::Marshaller<global::Game.Name> __Marshaller_game_Name = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Game.Name.Parser));
static readonly grpc::Marshaller<global::Game.UserID> __Marshaller_game_UserID = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Game.UserID.Parser)); static readonly grpc::Marshaller<global::Game.UserID> __Marshaller_game_UserID = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Game.UserID.Parser));
static readonly grpc::Marshaller<global::Game.LobbyCode> __Marshaller_game_LobbyCode = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Game.LobbyCode.Parser)); static readonly grpc::Marshaller<global::Game.LobbyCode> __Marshaller_game_LobbyCode = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Game.LobbyCode.Parser));
static readonly grpc::Marshaller<global::Game.LobbyConfig> __Marshaller_game_LobbyConfig = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Game.LobbyConfig.Parser));
static readonly grpc::Marshaller<global::Game.Game> __Marshaller_game_Game = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Game.Game.Parser));
static readonly grpc::Method<global::Game.Null, global::Game.Name> __Method_name = new grpc::Method<global::Game.Null, global::Game.Name>( static readonly grpc::Method<global::Game.Null, global::Game.Name> __Method_name = new grpc::Method<global::Game.Null, global::Game.Name>(
grpc::MethodType.Unary, grpc::MethodType.Unary,
@ -71,10 +73,24 @@ namespace Game {
__Marshaller_game_LobbyCode, __Marshaller_game_LobbyCode,
__Marshaller_game_Null); __Marshaller_game_Null);
static readonly grpc::Method<global::Game.Null, global::Game.LobbyCode> __Method_joinLobbyWithoutCode = new grpc::Method<global::Game.Null, global::Game.LobbyCode>( static readonly grpc::Method<global::Game.LobbyConfig, global::Game.LobbyCode> __Method_createLobby = new grpc::Method<global::Game.LobbyConfig, global::Game.LobbyCode>(
grpc::MethodType.Unary, grpc::MethodType.Unary,
__ServiceName, __ServiceName,
"joinLobbyWithoutCode", "createLobby",
__Marshaller_game_LobbyConfig,
__Marshaller_game_LobbyCode);
static readonly grpc::Method<global::Game.Null, global::Game.Game> __Method_getGames = new grpc::Method<global::Game.Null, global::Game.Game>(
grpc::MethodType.ServerStreaming,
__ServiceName,
"getGames",
__Marshaller_game_Null,
__Marshaller_game_Game);
static readonly grpc::Method<global::Game.Null, global::Game.LobbyCode> __Method_getPublicLobbies = new grpc::Method<global::Game.Null, global::Game.LobbyCode>(
grpc::MethodType.ServerStreaming,
__ServiceName,
"getPublicLobbies",
__Marshaller_game_Null, __Marshaller_game_Null,
__Marshaller_game_LobbyCode); __Marshaller_game_LobbyCode);
@ -103,7 +119,17 @@ namespace Game {
throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, "")); throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, ""));
} }
public virtual global::System.Threading.Tasks.Task<global::Game.LobbyCode> joinLobbyWithoutCode(global::Game.Null request, grpc::ServerCallContext context) public virtual global::System.Threading.Tasks.Task<global::Game.LobbyCode> createLobby(global::Game.LobbyConfig request, grpc::ServerCallContext context)
{
throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, ""));
}
public virtual global::System.Threading.Tasks.Task getGames(global::Game.Null request, grpc::IServerStreamWriter<global::Game.Game> responseStream, grpc::ServerCallContext context)
{
throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, ""));
}
public virtual global::System.Threading.Tasks.Task getPublicLobbies(global::Game.Null request, grpc::IServerStreamWriter<global::Game.LobbyCode> responseStream, grpc::ServerCallContext context)
{ {
throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, "")); throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, ""));
} }
@ -181,21 +207,37 @@ namespace Game {
{ {
return CallInvoker.AsyncUnaryCall(__Method_joinLobbyWithCode, null, options, request); return CallInvoker.AsyncUnaryCall(__Method_joinLobbyWithCode, null, options, request);
} }
public virtual global::Game.LobbyCode joinLobbyWithoutCode(global::Game.Null request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) public virtual global::Game.LobbyCode createLobby(global::Game.LobbyConfig request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
{
return createLobby(request, new grpc::CallOptions(headers, deadline, cancellationToken));
}
public virtual global::Game.LobbyCode createLobby(global::Game.LobbyConfig request, grpc::CallOptions options)
{
return CallInvoker.BlockingUnaryCall(__Method_createLobby, null, options, request);
}
public virtual grpc::AsyncUnaryCall<global::Game.LobbyCode> createLobbyAsync(global::Game.LobbyConfig request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
{
return createLobbyAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken));
}
public virtual grpc::AsyncUnaryCall<global::Game.LobbyCode> createLobbyAsync(global::Game.LobbyConfig request, grpc::CallOptions options)
{
return CallInvoker.AsyncUnaryCall(__Method_createLobby, null, options, request);
}
public virtual grpc::AsyncServerStreamingCall<global::Game.Game> getGames(global::Game.Null request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
{ {
return joinLobbyWithoutCode(request, new grpc::CallOptions(headers, deadline, cancellationToken)); return getGames(request, new grpc::CallOptions(headers, deadline, cancellationToken));
} }
public virtual global::Game.LobbyCode joinLobbyWithoutCode(global::Game.Null request, grpc::CallOptions options) public virtual grpc::AsyncServerStreamingCall<global::Game.Game> getGames(global::Game.Null request, grpc::CallOptions options)
{ {
return CallInvoker.BlockingUnaryCall(__Method_joinLobbyWithoutCode, null, options, request); return CallInvoker.AsyncServerStreamingCall(__Method_getGames, null, options, request);
} }
public virtual grpc::AsyncUnaryCall<global::Game.LobbyCode> joinLobbyWithoutCodeAsync(global::Game.Null request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) public virtual grpc::AsyncServerStreamingCall<global::Game.LobbyCode> getPublicLobbies(global::Game.Null request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
{ {
return joinLobbyWithoutCodeAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken)); return getPublicLobbies(request, new grpc::CallOptions(headers, deadline, cancellationToken));
} }
public virtual grpc::AsyncUnaryCall<global::Game.LobbyCode> joinLobbyWithoutCodeAsync(global::Game.Null request, grpc::CallOptions options) public virtual grpc::AsyncServerStreamingCall<global::Game.LobbyCode> getPublicLobbies(global::Game.Null request, grpc::CallOptions options)
{ {
return CallInvoker.AsyncUnaryCall(__Method_joinLobbyWithoutCode, null, options, request); return CallInvoker.AsyncServerStreamingCall(__Method_getPublicLobbies, null, options, request);
} }
/// <summary>Creates a new instance of client from given <c>ClientBaseConfiguration</c>.</summary> /// <summary>Creates a new instance of client from given <c>ClientBaseConfiguration</c>.</summary>
protected override ConnectionClient NewInstance(ClientBaseConfiguration configuration) protected override ConnectionClient NewInstance(ClientBaseConfiguration configuration)
@ -212,7 +254,9 @@ namespace Game {
.AddMethod(__Method_name, serviceImpl.name) .AddMethod(__Method_name, serviceImpl.name)
.AddMethod(__Method_connect, serviceImpl.connect) .AddMethod(__Method_connect, serviceImpl.connect)
.AddMethod(__Method_joinLobbyWithCode, serviceImpl.joinLobbyWithCode) .AddMethod(__Method_joinLobbyWithCode, serviceImpl.joinLobbyWithCode)
.AddMethod(__Method_joinLobbyWithoutCode, serviceImpl.joinLobbyWithoutCode).Build(); .AddMethod(__Method_createLobby, serviceImpl.createLobby)
.AddMethod(__Method_getGames, serviceImpl.getGames)
.AddMethod(__Method_getPublicLobbies, serviceImpl.getPublicLobbies).Build();
} }
/// <summary>Register service method with a service binder with or without implementation. Useful when customizing the service binding logic. /// <summary>Register service method with a service binder with or without implementation. Useful when customizing the service binding logic.
@ -224,7 +268,9 @@ namespace Game {
serviceBinder.AddMethod(__Method_name, serviceImpl == null ? null : new grpc::UnaryServerMethod<global::Game.Null, global::Game.Name>(serviceImpl.name)); serviceBinder.AddMethod(__Method_name, serviceImpl == null ? null : new grpc::UnaryServerMethod<global::Game.Null, global::Game.Name>(serviceImpl.name));
serviceBinder.AddMethod(__Method_connect, serviceImpl == null ? null : new grpc::UnaryServerMethod<global::Game.Name, global::Game.UserID>(serviceImpl.connect)); serviceBinder.AddMethod(__Method_connect, serviceImpl == null ? null : new grpc::UnaryServerMethod<global::Game.Name, global::Game.UserID>(serviceImpl.connect));
serviceBinder.AddMethod(__Method_joinLobbyWithCode, serviceImpl == null ? null : new grpc::UnaryServerMethod<global::Game.LobbyCode, global::Game.Null>(serviceImpl.joinLobbyWithCode)); serviceBinder.AddMethod(__Method_joinLobbyWithCode, serviceImpl == null ? null : new grpc::UnaryServerMethod<global::Game.LobbyCode, global::Game.Null>(serviceImpl.joinLobbyWithCode));
serviceBinder.AddMethod(__Method_joinLobbyWithoutCode, serviceImpl == null ? null : new grpc::UnaryServerMethod<global::Game.Null, global::Game.LobbyCode>(serviceImpl.joinLobbyWithoutCode)); serviceBinder.AddMethod(__Method_createLobby, serviceImpl == null ? null : new grpc::UnaryServerMethod<global::Game.LobbyConfig, global::Game.LobbyCode>(serviceImpl.createLobby));
serviceBinder.AddMethod(__Method_getGames, serviceImpl == null ? null : new grpc::ServerStreamingServerMethod<global::Game.Null, global::Game.Game>(serviceImpl.getGames));
serviceBinder.AddMethod(__Method_getPublicLobbies, serviceImpl == null ? null : new grpc::ServerStreamingServerMethod<global::Game.Null, global::Game.LobbyCode>(serviceImpl.getPublicLobbies));
} }
} }
@ -265,20 +311,12 @@ namespace Game {
return parser.ParseFrom(context.PayloadAsNewBuffer()); return parser.ParseFrom(context.PayloadAsNewBuffer());
} }
static readonly grpc::Marshaller<global::Game.Null> __Marshaller_game_Null = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Game.Null.Parser));
static readonly grpc::Marshaller<global::Game.Game> __Marshaller_game_Game = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Game.Game.Parser));
static readonly grpc::Marshaller<global::Game.CardID> __Marshaller_game_CardID = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Game.CardID.Parser)); static readonly grpc::Marshaller<global::Game.CardID> __Marshaller_game_CardID = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Game.CardID.Parser));
static readonly grpc::Marshaller<global::Game.Image> __Marshaller_game_Image = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Game.Image.Parser)); static readonly grpc::Marshaller<global::Game.Image> __Marshaller_game_Image = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Game.Image.Parser));
static readonly grpc::Marshaller<global::Game.Vote> __Marshaller_game_Vote = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Game.Vote.Parser)); static readonly grpc::Marshaller<global::Game.Vote> __Marshaller_game_Vote = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Game.Vote.Parser));
static readonly grpc::Marshaller<global::Game.Null> __Marshaller_game_Null = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Game.Null.Parser));
static readonly grpc::Marshaller<global::Game.LobbyStatus> __Marshaller_game_LobbyStatus = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Game.LobbyStatus.Parser)); static readonly grpc::Marshaller<global::Game.LobbyStatus> __Marshaller_game_LobbyStatus = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Game.LobbyStatus.Parser));
static readonly grpc::Method<global::Game.Null, global::Game.Game> __Method_getGames = new grpc::Method<global::Game.Null, global::Game.Game>(
grpc::MethodType.ServerStreaming,
__ServiceName,
"getGames",
__Marshaller_game_Null,
__Marshaller_game_Game);
static readonly grpc::Method<global::Game.CardID, global::Game.Image> __Method_getCardImage = new grpc::Method<global::Game.CardID, global::Game.Image>( static readonly grpc::Method<global::Game.CardID, global::Game.Image> __Method_getCardImage = new grpc::Method<global::Game.CardID, global::Game.Image>(
grpc::MethodType.Unary, grpc::MethodType.Unary,
__ServiceName, __ServiceName,
@ -317,11 +355,6 @@ namespace Game {
[grpc::BindServiceMethod(typeof(Lobby), "BindService")] [grpc::BindServiceMethod(typeof(Lobby), "BindService")]
public abstract partial class LobbyBase public abstract partial class LobbyBase
{ {
public virtual global::System.Threading.Tasks.Task getGames(global::Game.Null request, grpc::IServerStreamWriter<global::Game.Game> responseStream, grpc::ServerCallContext context)
{
throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, ""));
}
public virtual global::System.Threading.Tasks.Task<global::Game.Image> getCardImage(global::Game.CardID request, grpc::ServerCallContext context) public virtual global::System.Threading.Tasks.Task<global::Game.Image> getCardImage(global::Game.CardID request, grpc::ServerCallContext context)
{ {
throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, "")); throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, ""));
@ -367,14 +400,6 @@ namespace Game {
{ {
} }
public virtual grpc::AsyncServerStreamingCall<global::Game.Game> getGames(global::Game.Null request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
{
return getGames(request, new grpc::CallOptions(headers, deadline, cancellationToken));
}
public virtual grpc::AsyncServerStreamingCall<global::Game.Game> getGames(global::Game.Null request, grpc::CallOptions options)
{
return CallInvoker.AsyncServerStreamingCall(__Method_getGames, null, options, request);
}
public virtual global::Game.Image getCardImage(global::Game.CardID request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) public virtual global::Game.Image getCardImage(global::Game.CardID request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
{ {
return getCardImage(request, new grpc::CallOptions(headers, deadline, cancellationToken)); return getCardImage(request, new grpc::CallOptions(headers, deadline, cancellationToken));
@ -451,7 +476,6 @@ namespace Game {
public static grpc::ServerServiceDefinition BindService(LobbyBase serviceImpl) public static grpc::ServerServiceDefinition BindService(LobbyBase serviceImpl)
{ {
return grpc::ServerServiceDefinition.CreateBuilder() return grpc::ServerServiceDefinition.CreateBuilder()
.AddMethod(__Method_getGames, serviceImpl.getGames)
.AddMethod(__Method_getCardImage, serviceImpl.getCardImage) .AddMethod(__Method_getCardImage, serviceImpl.getCardImage)
.AddMethod(__Method_vote, serviceImpl.vote) .AddMethod(__Method_vote, serviceImpl.vote)
.AddMethod(__Method_ready, serviceImpl.ready) .AddMethod(__Method_ready, serviceImpl.ready)
@ -464,7 +488,6 @@ namespace Game {
/// <param name="serviceImpl">An object implementing the server-side handling logic.</param> /// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
public static void BindService(grpc::ServiceBinderBase serviceBinder, LobbyBase serviceImpl) public static void BindService(grpc::ServiceBinderBase serviceBinder, LobbyBase serviceImpl)
{ {
serviceBinder.AddMethod(__Method_getGames, serviceImpl == null ? null : new grpc::ServerStreamingServerMethod<global::Game.Null, global::Game.Game>(serviceImpl.getGames));
serviceBinder.AddMethod(__Method_getCardImage, serviceImpl == null ? null : new grpc::UnaryServerMethod<global::Game.CardID, global::Game.Image>(serviceImpl.getCardImage)); serviceBinder.AddMethod(__Method_getCardImage, serviceImpl == null ? null : new grpc::UnaryServerMethod<global::Game.CardID, global::Game.Image>(serviceImpl.getCardImage));
serviceBinder.AddMethod(__Method_vote, serviceImpl == null ? null : new grpc::UnaryServerMethod<global::Game.Vote, global::Game.Null>(serviceImpl.vote)); serviceBinder.AddMethod(__Method_vote, serviceImpl == null ? null : new grpc::UnaryServerMethod<global::Game.Vote, global::Game.Null>(serviceImpl.vote));
serviceBinder.AddMethod(__Method_ready, serviceImpl == null ? null : new grpc::UnaryServerMethod<global::Game.Null, global::Game.Null>(serviceImpl.ready)); serviceBinder.AddMethod(__Method_ready, serviceImpl == null ? null : new grpc::UnaryServerMethod<global::Game.Null, global::Game.Null>(serviceImpl.ready));

Loading…
Cancel
Save