Browse Source

Add simple card loading

new_protocol
ThePerkinrex 5 years ago
parent
commit
acf4c4c06c
No known key found for this signature in database GPG Key ID: 1F45A7C4BFB41607
  1. 18
      protobuf/game.proto
  2. 1
      server/.env
  3. 4
      server/.gitignore
  4. 25
      server/Cargo.toml
  5. 17
      server/build.rs
  6. 76
      server/schema/game-config.json
  7. 97
      server/src/db.rs
  8. 27
      server/src/db/types.rs
  9. 90
      server/src/games/config.rs
  10. 72
      server/src/games/mod.rs
  11. 66
      server/src/games/run.rs
  12. 94
      server/src/grpc.rs
  13. 1756
      server/src/grpc/game.rs
  14. 234
      server/src/grpc/game_grpc.rs
  15. 15
      server/src/main.rs
  16. 34
      server/src/setup.sql
  17. 51
      unity/Assets/Scripts/Base32.cs
  18. 11
      unity/Assets/Scripts/Base32.cs.meta
  19. 6
      unity/Assets/Scripts/Card.cs
  20. 75
      unity/Assets/Scripts/Client.cs
  21. 1
      unity/Assets/Scripts/DeckGenerator.cs
  22. 302
      unity/Assets/Scripts/grpc/Game.cs
  23. 82
      unity/Assets/Scripts/grpc/GameGrpc.cs

18
protobuf/game.proto

@ -4,24 +4,28 @@ package game;
// Interface exported by the server.
service Connection {
rpc joinLobbyWithCode(LobbyCode) returns(Result);
rpc connect(Username) returns(UserID);
rpc joinLobbyWithCode(LobbyCode) returns(Null);
rpc joinLobbyWithoutCode(Null) returns(LobbyCode);
}
service Lobby {
rpc getGames(Null) returns(stream Game);
rpc vote(Vote) returns(Result);
rpc ready (Null) returns (Result);
rpc vote(Vote) returns(Null);
rpc ready (Null) returns (Null);
rpc status (Null) returns (LobbyStatus);
}
message Null {}
message UserID {
string id = 1;
}
message Result {
enum Result { OK = 0; ERROR = 1; }
Result res = 1;
message Username {
string name = 1;
}
message Null {}
message LobbyCode { uint32 code = 1; }
message Game {

1
server/.env

@ -0,0 +1 @@
DATABASE_URL="sqlite:db.sqlite"

4
server/.gitignore

@ -1,2 +1,4 @@
/target
Cargo.lock
Cargo.lock
db.sqlite*
/games

25
server/Cargo.toml

@ -7,10 +7,25 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
grpc = "0.8.2"
protobuf = "2.18.0"
grpc-protobuf = "0.8.2"
# futures = "~0.3"
# Utilities
rand = "0.7.3"
uuid = {version = "0.8.1", features = ["v4"]}
tokio = {version = "0.2", features = ["full"]}
# Game loading
rhai = {version = "0.19.4", features = ["serde"]}
serde_json = "1.0.59"
serde = "1.0.117"
schemars = "0.8.0"
# GRPC stack
tonic = "0.3"
prost = "0.6"
# Database (SQLite)
sqlx = { version = "0.3", default-features = false, features = [ "runtime-tokio", "macros", "sqlite" ] }
[build-dependencies]
protoc-rust-grpc = "0.8.2"
# Grpc codegen
tonic-build = "0.3"

17
server/build.rs

@ -1,14 +1,17 @@
use std::fs::read_dir;
fn main() {
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut files = Vec::new();
for f in read_dir("../protobuf").unwrap() {
if let Ok(f) =f {
if let Ok(f) = f {
if f.path().is_file() && f.path().extension().map(|x| x == "proto").unwrap_or(false) {
if let Err(e) = protoc_rust_grpc::Codegen::new().include("../protobuf").input(f.path()).out_dir("src/grpc").rust_protobuf(true).run() {
eprintln!("PROTOC Error:\n{}", e);
std::process::exit(1)
}
files.push(f.path());
}
}
}
}
tonic_build::configure()
.build_client(false)
.out_dir("src/grpc")
.compile(&files, &["../protobuf".into()])?;
Ok(())
}

76
server/schema/game-config.json

@ -0,0 +1,76 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Config",
"type": "object",
"required": [
"available_cards",
"name",
"piles",
"player_piles",
"script"
],
"properties": {
"authors": {
"default": [],
"type": "array",
"items": {
"type": "string"
}
},
"available_cards": {
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/Card"
}
},
"name": {
"type": "string"
},
"piles": {
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/Pile"
}
},
"player_piles": {
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/Pile"
}
},
"script": {
"type": "string"
},
"version": {
"default": "0.0.0",
"type": "string"
}
},
"definitions": {
"Card": {
"type": "object",
"required": [
"image"
],
"properties": {
"image": {
"type": "string"
}
},
"additionalProperties": true
},
"Pile": {
"type": "object",
"properties": {
"cards": {
"default": [],
"type": "array",
"items": {
"type": "string"
}
}
},
"additionalProperties": true
}
}
}

97
server/src/db.rs

@ -0,0 +1,97 @@
use sqlx::{pool::PoolConnection, prelude::*, query, query_as, query_file, SqliteConnection, SqlitePool};
use tokio::stream::StreamExt;
pub mod types;
pub struct DbPool {
pool: SqlitePool,
}
impl DbPool {
pub async fn new() -> Self {
// std::env::set_var("DATABASE_URL", );
let pool = SqlitePool::new("sqlite:db.sqlite").await.unwrap();
let mut conn = pool.acquire().await.unwrap();
query_file!("src/setup.sql")
.execute(&mut conn)
.await
.unwrap();
Self { pool }
}
pub async fn acquire(&self) -> DbConnection {
DbConnection::new(self.pool.acquire().await.unwrap())
}
}
// impl Drop for DbPool {
// fn drop(&mut self) {
// tokio::runtime::Handle::current().block_on(future)
// }
// }
pub struct DbConnection {
conn: PoolConnection<SqliteConnection>,
}
use uuid::Uuid;
// TODO: return Results intead of crashing
impl DbConnection {
fn new(conn: PoolConnection<SqliteConnection>) -> Self {
Self { conn }
}
pub async fn add_user<T: ToString>(&mut self, name: T) -> Uuid {
let uuid = Uuid::new_v4();
// println!("{:?}", uuid.as_bytes().to_vec());
self.conn
.execute(query!(
"INSERT INTO Users(uuid, name) VALUES(?, ?)",
uuid.as_bytes().to_vec(),
name.to_string()
))
.await
.unwrap(); // Server crashes if uuids collide
uuid
}
pub async fn users(&mut self) -> Vec<types::User> {
query_as::<_, types::User>("SELECT UUID, Name FROM Users")
.fetch_all(&mut self.conn)
.await
.unwrap()
}
pub async fn create_lobby(&mut self) -> u32 {
let id = rand::random();
self.conn
.execute(query!(
"INSERT INTO Lobbies(id) VALUES(?)",
id as i32
))
.await
.unwrap(); // Server crashes if ids collide
id
}
pub async fn join_lobby(&mut self, user: Uuid, lobby: u32) {
self.conn
.execute(query!(
"INSERT INTO UsersInLobbies(UserId, LobbyId) VALUES(?, ?)",
user.as_bytes().to_vec(),
lobby as i32
))
.await
.unwrap(); // Server crashes if ids collide
}
pub async fn close(self) {
self.conn.close().await.unwrap();
}
}

27
server/src/db/types.rs

@ -0,0 +1,27 @@
use uuid::Uuid;
use sqlx::{prelude::*, sqlite::SqliteRow};
pub struct User{
pub name: String,
pub uuid: Uuid
}
impl<'a> FromRow<'a, SqliteRow<'a>> for User {
fn from_row(row: &SqliteRow<'a>) -> sqlx::Result<Self> {
let uuid: String = row.try_get("UUID")?;
// println!("{:?}", uuid.as_bytes());
Ok(Self {uuid: Uuid::from_slice(uuid.as_bytes()).map_err(|x| sqlx::Error::Decode(Box::new(x)))?, name: row.try_get("Name")?})
}
}
impl std::fmt::Display for User {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}[{}]", self.name, self.uuid)
}
}
impl std::fmt::Debug for User {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self)
}
}

90
server/src/games/config.rs

@ -0,0 +1,90 @@
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::path::PathBuf;
#[derive(Serialize, Deserialize, JsonSchema, Debug, Clone)]
pub struct Config {
pub name: String,
#[serde(default = "default_version")]
pub version: String,
#[serde(default)]
pub authors: Vec<String>,
pub script: String,
pub available_cards: HashMap<String, Card>,
pub piles: HashMap<String, Pile>,
pub player_piles: HashMap<String, Pile>,
}
fn default_version() -> String {
"0.0.0".into()
}
#[derive(Serialize, Deserialize, JsonSchema, Debug, Clone)]
pub struct Card {
pub image: PathBuf,
#[serde(flatten)]
pub other: HashMap<String, serde_json::Value>,
}
#[derive(Serialize, Deserialize, JsonSchema, Debug, Clone)]
pub struct Pile {
#[serde(default)]
pub cards: Vec<String>,
#[serde(flatten)]
pub other: HashMap<String, serde_json::Value>,
}
impl Pile {
pub fn from_rhai_map(map: rhai::Map) -> Result<Self, Box<rhai::EvalAltResult>> {
// println!("{}", map.get("cards")
// .ok_or("Pile doesn't have property cards")?.type_name());
let cards: Vec<String> =
rhai::serde::from_dynamic(map.get("cards").ok_or("Pile doesn't have property cards")?)?;
let other_fallible: Vec<Result<(String, serde_json::Value), Box<rhai::EvalAltResult>>> =
map.into_iter()
.map(|(x, v)| (x.to_string(), v))
.filter(|(s, _)| s != &"cards".to_string())
.map(|(k, v)| Ok((k, rhai::serde::from_dynamic::<serde_json::Value>(&v)?)))
.collect();
let mut other = HashMap::new();
for x in other_fallible {
let (k, v) = x?;
other.insert(k, v);
}
Ok(Self { cards, other })
}
}
impl Config {
pub fn load<P: AsRef<std::path::Path> + std::fmt::Debug>(file: P) -> Self {
serde_json::from_reader(std::fs::File::open(&file).unwrap())
.map_err(|e| {
eprintln!(
"Malformed game defintion file @ {}",
file.as_ref().display()
);
eprintln!("JSON Error: {}", e);
panic!()
})
.unwrap()
}
}
pub fn setup() {
if cfg!(debug_assertions) {
if let Ok(e) = std::env::var("CARGO_MANIFEST_DIR") {
std::fs::write(
AsRef::<std::path::Path>::as_ref(&e)
.join("schema")
.join("game-config.json"),
serde_json::to_string_pretty(&schemars::schema_for!(Config)).unwrap(),
)
.unwrap()
}
}
}

72
server/src/games/mod.rs

@ -0,0 +1,72 @@
use rhai::AST;
use std::fs::read_dir;
mod config;
mod run;
#[derive(Clone)]
pub struct Game {
name: String,
version: String,
authors: Vec<String>,
ast: AST,
conf: config::Config,
}
impl Game {
pub fn load<P: AsRef<std::path::Path> + std::fmt::Debug>(folder: P) -> Self {
// config::setup();
let conf = config::Config::load(folder.as_ref().join("game.json"));
let ast = rhai::Engine::new().compile_file(folder.as_ref().join(&conf.script)).unwrap();
println!("AST: {:?}", ast);
Self { conf: conf.clone(), name: conf.name, version: conf.version, authors: conf.authors, ast }
}
// pub fn name(&self) -> String {
// self.name.clone()
// }
// pub fn version(&self) -> String {
// self.version.clone()
// }
// pub fn authors(&self) -> Vec<String> {
// self.authors.clone()
// }
pub fn run(&self, players: u32) -> run::RunningGame {
run::RunningGame::new(self.ast.clone(), &self.conf, players)
}
}
impl std::fmt::Display for Game {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{} [{}]{}", self.name, self.version, if self.authors.is_empty() {String::new()} else {format!(" by {}", self.authors.join(", "))})
}
}
impl std::fmt::Debug for Game {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self)
}
}
pub fn load_games() -> Vec<Game> {
config::setup();
let mut games = Vec::new();
for file in read_dir("games").unwrap() {
if let Ok(folder) = file {
if folder.path().is_dir() {
for file in read_dir(folder.path()).unwrap() {
if let Ok(file) = file {
if file.file_name().to_str().unwrap() == "game.json" {
games.push(Game::load(folder.path()))
}
}
}
}
}
}
games
}

66
server/src/games/run.rs

@ -0,0 +1,66 @@
use rand::seq::SliceRandom;
use rhai::{
serde::{from_dynamic, to_dynamic},
Dynamic, Engine, Func, Map, RegisterResultFn, AST,
};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use super::config::{Config, Pile};
fn shuffle_pile(pile: Map) -> Result<Dynamic, Box<rhai::EvalAltResult>> {
let mut pile = Pile::from_rhai_map(pile)?;
let mut rng = rand::thread_rng();
pile.cards.shuffle(&mut rng);
to_dynamic(pile)
}
#[derive(Debug, Serialize, Deserialize, Clone)]
struct Setup {
piles: HashMap<String, Pile>,
player_piles: Vec<HashMap<String, Pile>>,
players: u32,
}
pub struct RunningGame {
piles: HashMap<String, Pile>,
player_piles: Vec<HashMap<String, Pile>>,
}
impl RunningGame {
pub fn new(ast: AST, conf: &Config, players: u32) -> Self {
let mut engine = Engine::new();
engine.register_result_fn("shuffle", shuffle_pile);
let setup = Func::<(Dynamic,), Dynamic>::create_from_ast(engine, ast, "setup");
let piles = conf.piles.clone();
let player_piles = vec![conf.player_piles.clone(); players as usize];
let Setup {
piles,
player_piles,
players: _,
} = from_dynamic(
&setup(
to_dynamic(Setup {
piles,
player_piles,
players,
})
.unwrap(),
)
.unwrap(),
)
.unwrap();
Self {
piles,
player_piles,
}
// Self {setup: Box::new(Func::<(Vec<Pile>, Vec<Vec<Pile>>), ()>::create_from_ast(engine, ast, "setup"))}
}
// pub fn setup(&self) {
// (self.setup)().unwrap()
// }
}

94
server/src/grpc.rs

@ -1,10 +1,88 @@
pub mod game;
pub mod game_grpc;
use tonic::{transport::Server, Request, Response, Status};
// use grpc::ServerBuilder;
use std::sync::Arc;
// pub fn start() {
// // let mut s = ServerBuilder::new();
// // s.add_service(game_grpc::ConnectionServer::new_service_def(handler))
// // let server = s.build().unwrap();
// }
mod game;
use game::connection_server::{Connection, ConnectionServer};
use game::{LobbyCode, Null, UserId, Username};
use crate::db;
pub struct ConnectionService {
conn: Arc<db::DbPool>,
}
#[tonic::async_trait]
impl Connection for ConnectionService {
async fn connect(&self, request: Request<Username>) -> Result<Response<UserId>, Status> {
let name = request.into_inner().name;
let mut conn = self.conn.acquire().await;
let uuid = conn.add_user(&name).await;
println!("Connected {}[{}]", name, uuid);
conn.close().await;
Ok(Response::new(UserId {
id: uuid.to_hyphenated().to_string(),
}))
}
async fn join_lobby_with_code(
&self,
request: Request<LobbyCode>,
) -> Result<Response<Null>, Status> {
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::MalformedUuid => Status::failed_precondition("malformed client_id")
})?;
let lobby = request.get_ref().code;
let mut conn = self.conn.acquire().await;
conn.join_lobby(uuid, lobby).await;
conn.close().await;
Ok(Response::new(Null{}))
}
async fn join_lobby_without_code(
&self,
request: Request<Null>,
) -> Result<Response<LobbyCode>, Status> {
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::MalformedUuid => Status::failed_precondition("malformed client_id")
})?;
let mut conn = self.conn.acquire().await;
let lobby = conn.create_lobby().await;
conn.join_lobby(uuid, lobby).await;
conn.close().await;
Ok(Response::new(LobbyCode{code: lobby}))
}
}
pub async fn start(pool: db::DbPool) {
let arc = Arc::new(pool);
let connection = ConnectionService { conn: arc.clone() };
Server::builder()
.add_service(ConnectionServer::new(connection))
.serve("0.0.0.0:50052".parse().unwrap())
.await
.unwrap();
}
mod client_id {
pub fn get(
metadata: &tonic::metadata::MetadataMap,
) -> Result<uuid::Uuid, Error> {
metadata
.get("client_id")
.ok_or(Error::NotSet)
.and_then(|x| {
uuid::Uuid::parse_str(x.to_str().map_err(|_| Error::MalformedUuid)?)
.map_err(|_| Error::MalformedUuid)
})
}
pub enum Error {
MalformedUuid,
NotSet,
}
}

1756
server/src/grpc/game.rs

File diff suppressed because it is too large

234
server/src/grpc/game_grpc.rs

@ -1,234 +0,0 @@
// This file is generated. Do not edit
// @generated
// https://github.com/Manishearth/rust-clippy/issues/702
#![allow(unknown_lints)]
#![allow(clippy::all)]
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(box_pointers)]
#![allow(dead_code)]
#![allow(missing_docs)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(non_upper_case_globals)]
#![allow(trivial_casts)]
#![allow(unsafe_code)]
#![allow(unused_imports)]
#![allow(unused_results)]
// server interface
pub trait Connection {
fn join_lobby_with_code(&self, o: ::grpc::ServerHandlerContext, req: ::grpc::ServerRequestSingle<super::game::LobbyCode>, resp: ::grpc::ServerResponseUnarySink<super::game::Result>) -> ::grpc::Result<()>;
fn join_lobby_without_code(&self, o: ::grpc::ServerHandlerContext, req: ::grpc::ServerRequestSingle<super::game::Null>, resp: ::grpc::ServerResponseUnarySink<super::game::LobbyCode>) -> ::grpc::Result<()>;
}
// client
pub struct ConnectionClient {
grpc_client: ::std::sync::Arc<::grpc::Client>,
}
impl ::grpc::ClientStub for ConnectionClient {
fn with_client(grpc_client: ::std::sync::Arc<::grpc::Client>) -> Self {
ConnectionClient {
grpc_client: grpc_client,
}
}
}
impl ConnectionClient {
pub fn join_lobby_with_code(&self, o: ::grpc::RequestOptions, req: super::game::LobbyCode) -> ::grpc::SingleResponse<super::game::Result> {
let descriptor = ::grpc::rt::ArcOrStatic::Static(&::grpc::rt::MethodDescriptor {
name: ::grpc::rt::StringOrStatic::Static("/game.Connection/joinLobbyWithCode"),
streaming: ::grpc::rt::GrpcStreaming::Unary,
req_marshaller: ::grpc::rt::ArcOrStatic::Static(&::grpc_protobuf::MarshallerProtobuf),
resp_marshaller: ::grpc::rt::ArcOrStatic::Static(&::grpc_protobuf::MarshallerProtobuf),
});
self.grpc_client.call_unary(o, req, descriptor)
}
pub fn join_lobby_without_code(&self, o: ::grpc::RequestOptions, req: super::game::Null) -> ::grpc::SingleResponse<super::game::LobbyCode> {
let descriptor = ::grpc::rt::ArcOrStatic::Static(&::grpc::rt::MethodDescriptor {
name: ::grpc::rt::StringOrStatic::Static("/game.Connection/joinLobbyWithoutCode"),
streaming: ::grpc::rt::GrpcStreaming::Unary,
req_marshaller: ::grpc::rt::ArcOrStatic::Static(&::grpc_protobuf::MarshallerProtobuf),
resp_marshaller: ::grpc::rt::ArcOrStatic::Static(&::grpc_protobuf::MarshallerProtobuf),
});
self.grpc_client.call_unary(o, req, descriptor)
}
}
// server
pub struct ConnectionServer;
impl ConnectionServer {
pub fn new_service_def<H : Connection + 'static + Sync + Send + 'static>(handler: H) -> ::grpc::rt::ServerServiceDefinition {
let handler_arc = ::std::sync::Arc::new(handler);
::grpc::rt::ServerServiceDefinition::new("/game.Connection",
vec![
::grpc::rt::ServerMethod::new(
::grpc::rt::ArcOrStatic::Static(&::grpc::rt::MethodDescriptor {
name: ::grpc::rt::StringOrStatic::Static("/game.Connection/joinLobbyWithCode"),
streaming: ::grpc::rt::GrpcStreaming::Unary,
req_marshaller: ::grpc::rt::ArcOrStatic::Static(&::grpc_protobuf::MarshallerProtobuf),
resp_marshaller: ::grpc::rt::ArcOrStatic::Static(&::grpc_protobuf::MarshallerProtobuf),
}),
{
let handler_copy = handler_arc.clone();
::grpc::rt::MethodHandlerUnary::new(move |ctx, req, resp| (*handler_copy).join_lobby_with_code(ctx, req, resp))
},
),
::grpc::rt::ServerMethod::new(
::grpc::rt::ArcOrStatic::Static(&::grpc::rt::MethodDescriptor {
name: ::grpc::rt::StringOrStatic::Static("/game.Connection/joinLobbyWithoutCode"),
streaming: ::grpc::rt::GrpcStreaming::Unary,
req_marshaller: ::grpc::rt::ArcOrStatic::Static(&::grpc_protobuf::MarshallerProtobuf),
resp_marshaller: ::grpc::rt::ArcOrStatic::Static(&::grpc_protobuf::MarshallerProtobuf),
}),
{
let handler_copy = handler_arc.clone();
::grpc::rt::MethodHandlerUnary::new(move |ctx, req, resp| (*handler_copy).join_lobby_without_code(ctx, req, resp))
},
),
],
)
}
}
// server interface
pub trait Lobby {
fn get_games(&self, o: ::grpc::ServerHandlerContext, req: ::grpc::ServerRequestSingle<super::game::Null>, resp: ::grpc::ServerResponseSink<super::game::Game>) -> ::grpc::Result<()>;
fn vote(&self, o: ::grpc::ServerHandlerContext, req: ::grpc::ServerRequestSingle<super::game::Vote>, resp: ::grpc::ServerResponseUnarySink<super::game::Result>) -> ::grpc::Result<()>;
fn ready(&self, o: ::grpc::ServerHandlerContext, req: ::grpc::ServerRequestSingle<super::game::Null>, resp: ::grpc::ServerResponseUnarySink<super::game::Result>) -> ::grpc::Result<()>;
fn status(&self, o: ::grpc::ServerHandlerContext, req: ::grpc::ServerRequestSingle<super::game::Null>, resp: ::grpc::ServerResponseUnarySink<super::game::LobbyStatus>) -> ::grpc::Result<()>;
}
// client
pub struct LobbyClient {
grpc_client: ::std::sync::Arc<::grpc::Client>,
}
impl ::grpc::ClientStub for LobbyClient {
fn with_client(grpc_client: ::std::sync::Arc<::grpc::Client>) -> Self {
LobbyClient {
grpc_client: grpc_client,
}
}
}
impl LobbyClient {
pub fn get_games(&self, o: ::grpc::RequestOptions, req: super::game::Null) -> ::grpc::StreamingResponse<super::game::Game> {
let descriptor = ::grpc::rt::ArcOrStatic::Static(&::grpc::rt::MethodDescriptor {
name: ::grpc::rt::StringOrStatic::Static("/game.Lobby/getGames"),
streaming: ::grpc::rt::GrpcStreaming::ServerStreaming,
req_marshaller: ::grpc::rt::ArcOrStatic::Static(&::grpc_protobuf::MarshallerProtobuf),
resp_marshaller: ::grpc::rt::ArcOrStatic::Static(&::grpc_protobuf::MarshallerProtobuf),
});
self.grpc_client.call_server_streaming(o, req, descriptor)
}
pub fn vote(&self, o: ::grpc::RequestOptions, req: super::game::Vote) -> ::grpc::SingleResponse<super::game::Result> {
let descriptor = ::grpc::rt::ArcOrStatic::Static(&::grpc::rt::MethodDescriptor {
name: ::grpc::rt::StringOrStatic::Static("/game.Lobby/vote"),
streaming: ::grpc::rt::GrpcStreaming::Unary,
req_marshaller: ::grpc::rt::ArcOrStatic::Static(&::grpc_protobuf::MarshallerProtobuf),
resp_marshaller: ::grpc::rt::ArcOrStatic::Static(&::grpc_protobuf::MarshallerProtobuf),
});
self.grpc_client.call_unary(o, req, descriptor)
}
pub fn ready(&self, o: ::grpc::RequestOptions, req: super::game::Null) -> ::grpc::SingleResponse<super::game::Result> {
let descriptor = ::grpc::rt::ArcOrStatic::Static(&::grpc::rt::MethodDescriptor {
name: ::grpc::rt::StringOrStatic::Static("/game.Lobby/ready"),
streaming: ::grpc::rt::GrpcStreaming::Unary,
req_marshaller: ::grpc::rt::ArcOrStatic::Static(&::grpc_protobuf::MarshallerProtobuf),
resp_marshaller: ::grpc::rt::ArcOrStatic::Static(&::grpc_protobuf::MarshallerProtobuf),
});
self.grpc_client.call_unary(o, req, descriptor)
}
pub fn status(&self, o: ::grpc::RequestOptions, req: super::game::Null) -> ::grpc::SingleResponse<super::game::LobbyStatus> {
let descriptor = ::grpc::rt::ArcOrStatic::Static(&::grpc::rt::MethodDescriptor {
name: ::grpc::rt::StringOrStatic::Static("/game.Lobby/status"),
streaming: ::grpc::rt::GrpcStreaming::Unary,
req_marshaller: ::grpc::rt::ArcOrStatic::Static(&::grpc_protobuf::MarshallerProtobuf),
resp_marshaller: ::grpc::rt::ArcOrStatic::Static(&::grpc_protobuf::MarshallerProtobuf),
});
self.grpc_client.call_unary(o, req, descriptor)
}
}
// server
pub struct LobbyServer;
impl LobbyServer {
pub fn new_service_def<H : Lobby + 'static + Sync + Send + 'static>(handler: H) -> ::grpc::rt::ServerServiceDefinition {
let handler_arc = ::std::sync::Arc::new(handler);
::grpc::rt::ServerServiceDefinition::new("/game.Lobby",
vec![
::grpc::rt::ServerMethod::new(
::grpc::rt::ArcOrStatic::Static(&::grpc::rt::MethodDescriptor {
name: ::grpc::rt::StringOrStatic::Static("/game.Lobby/getGames"),
streaming: ::grpc::rt::GrpcStreaming::ServerStreaming,
req_marshaller: ::grpc::rt::ArcOrStatic::Static(&::grpc_protobuf::MarshallerProtobuf),
resp_marshaller: ::grpc::rt::ArcOrStatic::Static(&::grpc_protobuf::MarshallerProtobuf),
}),
{
let handler_copy = handler_arc.clone();
::grpc::rt::MethodHandlerServerStreaming::new(move |ctx, req, resp| (*handler_copy).get_games(ctx, req, resp))
},
),
::grpc::rt::ServerMethod::new(
::grpc::rt::ArcOrStatic::Static(&::grpc::rt::MethodDescriptor {
name: ::grpc::rt::StringOrStatic::Static("/game.Lobby/vote"),
streaming: ::grpc::rt::GrpcStreaming::Unary,
req_marshaller: ::grpc::rt::ArcOrStatic::Static(&::grpc_protobuf::MarshallerProtobuf),
resp_marshaller: ::grpc::rt::ArcOrStatic::Static(&::grpc_protobuf::MarshallerProtobuf),
}),
{
let handler_copy = handler_arc.clone();
::grpc::rt::MethodHandlerUnary::new(move |ctx, req, resp| (*handler_copy).vote(ctx, req, resp))
},
),
::grpc::rt::ServerMethod::new(
::grpc::rt::ArcOrStatic::Static(&::grpc::rt::MethodDescriptor {
name: ::grpc::rt::StringOrStatic::Static("/game.Lobby/ready"),
streaming: ::grpc::rt::GrpcStreaming::Unary,
req_marshaller: ::grpc::rt::ArcOrStatic::Static(&::grpc_protobuf::MarshallerProtobuf),
resp_marshaller: ::grpc::rt::ArcOrStatic::Static(&::grpc_protobuf::MarshallerProtobuf),
}),
{
let handler_copy = handler_arc.clone();
::grpc::rt::MethodHandlerUnary::new(move |ctx, req, resp| (*handler_copy).ready(ctx, req, resp))
},
),
::grpc::rt::ServerMethod::new(
::grpc::rt::ArcOrStatic::Static(&::grpc::rt::MethodDescriptor {
name: ::grpc::rt::StringOrStatic::Static("/game.Lobby/status"),
streaming: ::grpc::rt::GrpcStreaming::Unary,
req_marshaller: ::grpc::rt::ArcOrStatic::Static(&::grpc_protobuf::MarshallerProtobuf),
resp_marshaller: ::grpc::rt::ArcOrStatic::Static(&::grpc_protobuf::MarshallerProtobuf),
}),
{
let handler_copy = handler_arc.clone();
::grpc::rt::MethodHandlerUnary::new(move |ctx, req, resp| (*handler_copy).status(ctx, req, resp))
},
),
],
)
}
}

15
server/src/main.rs

@ -1,6 +1,17 @@
mod grpc;
mod db;
mod games;
fn main() {
#[tokio::main]
async fn main() {
// protobuf::route_guide_grpc::RouteGuid
println!("Hello, world!");
let games = games::load_games();
println!("{:?}", games);
games[0].run(4);
// let pool = db::DbPool::new().await;
// let mut conn = pool.acquire().await;
// println!("{}", conn.add_user("Hi").await);
// println!("{:?}", conn.users().await);
// conn.close().await;
// grpc::start(pool).await;
}

34
server/src/setup.sql

@ -0,0 +1,34 @@
-- Add migration script here
DROP TABLE IF EXISTS `UsersInLobbies`;
DROP TABLE IF EXISTS `Users`;
DROP TABLE IF EXISTS `Lobbies`;
CREATE TABLE Users (
UUID CHAR(16) NOT NULL UNIQUE PRIMARY KEY,
Name VARCHAR(255) NOT NULL
-- LobbyID INT NULL,
-- FOREIGN KEY (LobbyID) REFERENCES Lobbies(ID)
);
CREATE TABLE Lobbies (
ID INT NOT NULL UNIQUE PRIMARY KEY
);
CREATE TABLE UsersInLobbies (
LobbyID INT NOT NULL,
UserID CHAR(16) NOT NULL UNIQUE,
FOREIGN KEY (LobbyID) REFERENCES Lobbies(ID),
FOREIGN KEY (UserID) REFERENCES Users(UUID)
);
-- INSERT INTO Users(UUID, Name) VALUES("0123456789abcdef", "Hi");
-- INSERT INTO Lobbies(ID) VALUES(0);
-- INSERT INTO Users(UUID, Name) VALUES("0123456789abcdff", "Hi2");
-- INSERT INTO UsersInLobbies(UserID,LobbyID) VALUES("0123456789abcdff", 0);
-- INSERT INTO Users(UUID, Name) VALUES("0123456789abcdfe", "Hi3");
-- INSERT INTO UsersInLobbies(UserID,LobbyID) VALUES("0123456789abcdfe", 1);

51
unity/Assets/Scripts/Base32.cs

@ -0,0 +1,51 @@
// using UnityEngine;
public static class Base32
{
private const string CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUV";
public static string ToString(uint number)
{
uint quotient = number / 32;
uint remainder = number % 32;
string res = CHARS[(int)remainder].ToString();
// Debug.Log(res);
// Debug.Log("Q " + quotient);
// Debug.Log("R " + remainder + " > " + res);
if (quotient > 0)
{
res = ToString(quotient) + res;
}
return res;
}
public static uint FromString(string s)
{
uint res = 0;
if (s.Length > 0)
{
for (int i = 0; i < s.Length; i++)
{
uint pow = UIntPow(32, (uint)i);
// Debug.Log();
res += ((uint)CHARS.IndexOf(s[s.Length - 1 - i])) * pow;
// Debug.Log(i + ":" + pow + " | " + s[i] + " " + CHARS.IndexOf(s[s.Length - 1 - i]) + " > " + res);
}
}
return res;
}
private static uint UIntPow(uint x, uint pow)
{
uint ret = 1;
while (pow != 0)
{
if ((pow & 1) == 1)
ret *= x;
x *= x;
pow >>= 1;
}
return ret;
}
}

11
unity/Assets/Scripts/Base32.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 35e876ff614b5e8f5b1cc702b9502b5c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

6
unity/Assets/Scripts/Card.cs

@ -36,7 +36,13 @@ public class Card : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler{
}
}
public void OnClickCard() {
// var conn = Client.GetConnection();
// if (conn != null) {
// Debug.Log(conn.GetLobby());
// Debug.Log(conn.CreateLobby());
// }
if ((!preparingCard || cardBeingPrepared != gameObject) && !thrown) {
cardBeingPrepared = gameObject;
SetPreview();
preparingCard = true;

75
unity/Assets/Scripts/Client.cs

@ -1,13 +1,68 @@
using UnityEngine;
using Grpc.Core;
using Game;
public class Client: MonoBehaviour
// using UnityEngine;
public static class Client
{
public void Run() {
Channel channel = new Channel("127.0.0.1:50052", ChannelCredentials.Insecure);
var client = new Connection.ConnectionClient(channel);
// Client code goes here
channel.ShutdownAsync().Wait();
private static Connection reference;
public static void Connect(string name)
{
reference = new Connection(name);
}
public static ref Connection GetConnection()
{
return ref reference;
}
public static void CloseConnection()
{
if (reference != null)
{
reference.Close();
reference = null;
}
}
public class Connection // : MonoBehaviour
{
private Game.Connection.ConnectionClient connection;
private Channel channel;
private string connId;
private uint? lobby = null;
public Connection(string user)
{
channel = new Channel("127.0.0.1:50052", ChannelCredentials.Insecure);
connection = new Game.Connection.ConnectionClient(channel);
connId = connection.connect(new Game.Username { Name = user }).Id;
}
public void JoinLobby(string code)
{
lobby = Base32.FromString(code);
connection.joinLobbyWithCode(new Game.LobbyCode { Code = (uint)lobby }, new Metadata { new Metadata.Entry("client_id", connId) });
}
public string CreateLobby()
{
lobby = connection.joinLobbyWithoutCode(new Game.Null(), new Metadata { new Metadata.Entry("client_id", connId) }).Code;
return Base32.ToString((uint)lobby);
}
public string GetLobby()
{
if (lobby != null)
{
return Base32.ToString((uint)lobby);
}
else
{
return null;
}
}
public void Close()
{
channel.ShutdownAsync().Wait();
}
}
}
}

1
unity/Assets/Scripts/DeckGenerator.cs

@ -23,6 +23,7 @@ public class DeckGenerator : MonoBehaviour
private string defaultbg;
// Start is called before the first frame update
void Start() {
// Client.Connect("PooPoo2");
if(deckUI && cardPrefab && deckFileName != "") {
string path = Application.streamingAssetsPath + "/" + deckFileName;
var deckFile = new TextAsset(File.ReadAllText(path));

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

@ -24,25 +24,27 @@ namespace Game {
static GameReflection() {
byte[] descriptorData = global::System.Convert.FromBase64String(
string.Concat(
"CgpnYW1lLnByb3RvEgRnYW1lIgYKBE51bGwiRwoGUmVzdWx0EiAKA3JlcxgB",
"IAEoDjITLmdhbWUuUmVzdWx0LlJlc3VsdCIbCgZSZXN1bHQSBgoCT0sQABIJ",
"CgVFUlJPUhABIhkKCUxvYmJ5Q29kZRIMCgRjb2RlGAEgASgNIkIKBEdhbWUS",
"DAoEbmFtZRgBIAEoCRIPCgd2ZXJzaW9uGAIgASgJEg8KB2F1dGhvcnMYAyAD",
"KAkSCgoCaWQYBCABKAQiEgoEVm90ZRIKCgJpZBgBIAEoBCJZCgtMb2JieVN0",
"YXR1cxIZCgV2b3RlcxgBIAMoCzIKLmdhbWUuVm90ZRIbCgVyZWFkeRgCIAMo",
"CzIMLmdhbWUuUGxheWVyEhIKCmlzU3RhcnRpbmcYAyABKAgiIgoGUGxheWVy",
"EgwKBG5hbWUYASABKAkSCgoCaWQYAiABKAQydQoKQ29ubmVjdGlvbhIyChFq",
"b2luTG9iYnlXaXRoQ29kZRIPLmdhbWUuTG9iYnlDb2RlGgwuZ2FtZS5SZXN1",
"bHQSMwoUam9pbkxvYmJ5V2l0aG91dENvZGUSCi5nYW1lLk51bGwaDy5nYW1l",
"LkxvYmJ5Q29kZTKbAQoFTG9iYnkSJAoIZ2V0R2FtZXMSCi5nYW1lLk51bGwa",
"Ci5nYW1lLkdhbWUwARIgCgR2b3RlEgouZ2FtZS5Wb3RlGgwuZ2FtZS5SZXN1",
"bHQSIQoFcmVhZHkSCi5nYW1lLk51bGwaDC5nYW1lLlJlc3VsdBInCgZzdGF0",
"dXMSCi5nYW1lLk51bGwaES5nYW1lLkxvYmJ5U3RhdHVzYgZwcm90bzM="));
"CgpnYW1lLnByb3RvEgRnYW1lIhQKBlVzZXJJRBIKCgJpZBgBIAEoCSIYCghV",
"c2VybmFtZRIMCgRuYW1lGAEgASgJIgYKBE51bGwiGQoJTG9iYnlDb2RlEgwK",
"BGNvZGUYASABKA0iQgoER2FtZRIMCgRuYW1lGAEgASgJEg8KB3ZlcnNpb24Y",
"AiABKAkSDwoHYXV0aG9ycxgDIAMoCRIKCgJpZBgEIAEoBCISCgRWb3RlEgoK",
"AmlkGAEgASgEIlkKC0xvYmJ5U3RhdHVzEhkKBXZvdGVzGAEgAygLMgouZ2Ft",
"ZS5Wb3RlEhsKBXJlYWR5GAIgAygLMgwuZ2FtZS5QbGF5ZXISEgoKaXNTdGFy",
"dGluZxgDIAEoCCIiCgZQbGF5ZXISDAoEbmFtZRgBIAEoCRIKCgJpZBgCIAEo",
"BDKcAQoKQ29ubmVjdGlvbhInCgdjb25uZWN0Eg4uZ2FtZS5Vc2VybmFtZRoM",
"LmdhbWUuVXNlcklEEjAKEWpvaW5Mb2JieVdpdGhDb2RlEg8uZ2FtZS5Mb2Ji",
"eUNvZGUaCi5nYW1lLk51bGwSMwoUam9pbkxvYmJ5V2l0aG91dENvZGUSCi5n",
"YW1lLk51bGwaDy5nYW1lLkxvYmJ5Q29kZTKXAQoFTG9iYnkSJAoIZ2V0R2Ft",
"ZXMSCi5nYW1lLk51bGwaCi5nYW1lLkdhbWUwARIeCgR2b3RlEgouZ2FtZS5W",
"b3RlGgouZ2FtZS5OdWxsEh8KBXJlYWR5EgouZ2FtZS5OdWxsGgouZ2FtZS5O",
"dWxsEicKBnN0YXR1cxIKLmdhbWUuTnVsbBoRLmdhbWUuTG9iYnlTdGF0dXNi",
"BnByb3RvMw=="));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { },
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.Username), global::Game.Username.Parser, new[]{ "Name" }, 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.Result), global::Game.Result.Parser, new[]{ "Res" }, null, new[]{ typeof(global::Game.Result.Types.Result) }, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Game.LobbyCode), global::Game.LobbyCode.Parser, new[]{ "Code" }, null, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Game.Game), global::Game.Game.Parser, new[]{ "Name", "Version", "Authors", "Id" }, null, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Game.Vote), global::Game.Vote.Parser, new[]{ "Id" }, null, null, null, null),
@ -54,15 +56,15 @@ namespace Game {
}
#region Messages
public sealed partial class Null : pb::IMessage<Null>
public sealed partial class UserID : pb::IMessage<UserID>
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
, pb::IBufferMessage
#endif
{
private static readonly pb::MessageParser<Null> _parser = new pb::MessageParser<Null>(() => new Null());
private static readonly pb::MessageParser<UserID> _parser = new pb::MessageParser<UserID>(() => new UserID());
private pb::UnknownFieldSet _unknownFields;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pb::MessageParser<Null> Parser { get { return _parser; } }
public static pb::MessageParser<UserID> Parser { get { return _parser; } }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pbr::MessageDescriptor Descriptor {
@ -75,41 +77,55 @@ namespace Game {
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public Null() {
public UserID() {
OnConstruction();
}
partial void OnConstruction();
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public Null(Null other) : this() {
public UserID(UserID other) : this() {
id_ = other.id_;
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public Null Clone() {
return new Null(this);
public UserID Clone() {
return new UserID(this);
}
/// <summary>Field number for the "id" field.</summary>
public const int IdFieldNumber = 1;
private string id_ = "";
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string Id {
get { return id_; }
set {
id_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
}
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override bool Equals(object other) {
return Equals(other as Null);
return Equals(other as UserID);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public bool Equals(Null other) {
public bool Equals(UserID other) {
if (ReferenceEquals(other, null)) {
return false;
}
if (ReferenceEquals(other, this)) {
return true;
}
if (Id != other.Id) return false;
return Equals(_unknownFields, other._unknownFields);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override int GetHashCode() {
int hash = 1;
if (Id.Length != 0) hash ^= Id.GetHashCode();
if (_unknownFields != null) {
hash ^= _unknownFields.GetHashCode();
}
@ -126,6 +142,10 @@ namespace Game {
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
output.WriteRawMessage(this);
#else
if (Id.Length != 0) {
output.WriteRawTag(10);
output.WriteString(Id);
}
if (_unknownFields != null) {
_unknownFields.WriteTo(output);
}
@ -135,6 +155,10 @@ namespace Game {
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) {
if (Id.Length != 0) {
output.WriteRawTag(10);
output.WriteString(Id);
}
if (_unknownFields != null) {
_unknownFields.WriteTo(ref output);
}
@ -144,6 +168,9 @@ namespace Game {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int CalculateSize() {
int size = 0;
if (Id.Length != 0) {
size += 1 + pb::CodedOutputStream.ComputeStringSize(Id);
}
if (_unknownFields != null) {
size += _unknownFields.CalculateSize();
}
@ -151,10 +178,13 @@ namespace Game {
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void MergeFrom(Null other) {
public void MergeFrom(UserID other) {
if (other == null) {
return;
}
if (other.Id.Length != 0) {
Id = other.Id;
}
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
}
@ -169,6 +199,10 @@ namespace Game {
default:
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
Id = input.ReadString();
break;
}
}
}
#endif
@ -183,6 +217,10 @@ namespace Game {
default:
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input);
break;
case 10: {
Id = input.ReadString();
break;
}
}
}
}
@ -190,15 +228,15 @@ namespace Game {
}
public sealed partial class Result : pb::IMessage<Result>
public sealed partial class Username : pb::IMessage<Username>
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
, pb::IBufferMessage
#endif
{
private static readonly pb::MessageParser<Result> _parser = new pb::MessageParser<Result>(() => new Result());
private static readonly pb::MessageParser<Username> _parser = new pb::MessageParser<Username>(() => new Username());
private pb::UnknownFieldSet _unknownFields;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pb::MessageParser<Result> Parser { get { return _parser; } }
public static pb::MessageParser<Username> Parser { get { return _parser; } }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pbr::MessageDescriptor Descriptor {
@ -211,55 +249,55 @@ namespace Game {
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public Result() {
public Username() {
OnConstruction();
}
partial void OnConstruction();
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public Result(Result other) : this() {
res_ = other.res_;
public Username(Username other) : this() {
name_ = other.name_;
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public Result Clone() {
return new Result(this);
public Username Clone() {
return new Username(this);
}
/// <summary>Field number for the "res" field.</summary>
public const int ResFieldNumber = 1;
private global::Game.Result.Types.Result res_ = global::Game.Result.Types.Result.Ok;
/// <summary>Field number for the "name" field.</summary>
public const int NameFieldNumber = 1;
private string name_ = "";
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public global::Game.Result.Types.Result Res {
get { return res_; }
public string Name {
get { return name_; }
set {
res_ = value;
name_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
}
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override bool Equals(object other) {
return Equals(other as Result);
return Equals(other as Username);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public bool Equals(Result other) {
public bool Equals(Username other) {
if (ReferenceEquals(other, null)) {
return false;
}
if (ReferenceEquals(other, this)) {
return true;
}
if (Res != other.Res) return false;
if (Name != other.Name) return false;
return Equals(_unknownFields, other._unknownFields);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override int GetHashCode() {
int hash = 1;
if (Res != global::Game.Result.Types.Result.Ok) hash ^= Res.GetHashCode();
if (Name.Length != 0) hash ^= Name.GetHashCode();
if (_unknownFields != null) {
hash ^= _unknownFields.GetHashCode();
}
@ -276,9 +314,9 @@ namespace Game {
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
output.WriteRawMessage(this);
#else
if (Res != global::Game.Result.Types.Result.Ok) {
output.WriteRawTag(8);
output.WriteEnum((int) Res);
if (Name.Length != 0) {
output.WriteRawTag(10);
output.WriteString(Name);
}
if (_unknownFields != null) {
_unknownFields.WriteTo(output);
@ -289,9 +327,9 @@ namespace Game {
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) {
if (Res != global::Game.Result.Types.Result.Ok) {
output.WriteRawTag(8);
output.WriteEnum((int) Res);
if (Name.Length != 0) {
output.WriteRawTag(10);
output.WriteString(Name);
}
if (_unknownFields != null) {
_unknownFields.WriteTo(ref output);
@ -302,8 +340,8 @@ namespace Game {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int CalculateSize() {
int size = 0;
if (Res != global::Game.Result.Types.Result.Ok) {
size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Res);
if (Name.Length != 0) {
size += 1 + pb::CodedOutputStream.ComputeStringSize(Name);
}
if (_unknownFields != null) {
size += _unknownFields.CalculateSize();
@ -312,12 +350,12 @@ namespace Game {
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void MergeFrom(Result other) {
public void MergeFrom(Username other) {
if (other == null) {
return;
}
if (other.Res != global::Game.Result.Types.Result.Ok) {
Res = other.Res;
if (other.Name.Length != 0) {
Name = other.Name;
}
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
}
@ -333,8 +371,8 @@ namespace Game {
default:
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 8: {
Res = (global::Game.Result.Types.Result) input.ReadEnum();
case 10: {
Name = input.ReadString();
break;
}
}
@ -351,8 +389,8 @@ namespace Game {
default:
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input);
break;
case 8: {
Res = (global::Game.Result.Types.Result) input.ReadEnum();
case 10: {
Name = input.ReadString();
break;
}
}
@ -360,17 +398,141 @@ namespace Game {
}
#endif
#region Nested types
/// <summary>Container for nested types declared in the Result message type.</summary>
}
public sealed partial class Null : pb::IMessage<Null>
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
, pb::IBufferMessage
#endif
{
private static readonly pb::MessageParser<Null> _parser = new pb::MessageParser<Null>(() => new Null());
private pb::UnknownFieldSet _unknownFields;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pb::MessageParser<Null> 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 Null() {
OnConstruction();
}
partial void OnConstruction();
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static partial class Types {
public enum Result {
[pbr::OriginalName("OK")] Ok = 0,
[pbr::OriginalName("ERROR")] Error = 1,
public Null(Null other) : this() {
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public Null Clone() {
return new Null(this);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override bool Equals(object other) {
return Equals(other as Null);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public bool Equals(Null other) {
if (ReferenceEquals(other, null)) {
return false;
}
if (ReferenceEquals(other, this)) {
return true;
}
return Equals(_unknownFields, other._unknownFields);
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override int GetHashCode() {
int hash = 1;
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 (_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 (_unknownFields != null) {
_unknownFields.WriteTo(ref output);
}
}
#endif
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int CalculateSize() {
int size = 0;
if (_unknownFields != null) {
size += _unknownFields.CalculateSize();
}
return size;
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void MergeFrom(Null other) {
if (other == null) {
return;
}
_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;
}
}
#endif
}
#endregion
#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;
}
}
}
#endif
}
@ -386,7 +548,7 @@ namespace Game {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
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]
@ -558,7 +720,7 @@ namespace Game {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
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]
@ -827,7 +989,7 @@ namespace Game {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
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]
@ -999,7 +1161,7 @@ namespace Game {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
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]
@ -1221,7 +1383,7 @@ namespace Game {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
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]

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

@ -45,16 +45,24 @@ namespace Game {
return parser.ParseFrom(context.PayloadAsNewBuffer());
}
static readonly grpc::Marshaller<global::Game.Username> __Marshaller_game_Username = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Game.Username.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.Result> __Marshaller_game_Result = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Game.Result.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::Method<global::Game.LobbyCode, global::Game.Result> __Method_joinLobbyWithCode = new grpc::Method<global::Game.LobbyCode, global::Game.Result>(
static readonly grpc::Method<global::Game.Username, global::Game.UserID> __Method_connect = new grpc::Method<global::Game.Username, global::Game.UserID>(
grpc::MethodType.Unary,
__ServiceName,
"connect",
__Marshaller_game_Username,
__Marshaller_game_UserID);
static readonly grpc::Method<global::Game.LobbyCode, global::Game.Null> __Method_joinLobbyWithCode = new grpc::Method<global::Game.LobbyCode, global::Game.Null>(
grpc::MethodType.Unary,
__ServiceName,
"joinLobbyWithCode",
__Marshaller_game_LobbyCode,
__Marshaller_game_Result);
__Marshaller_game_Null);
static readonly grpc::Method<global::Game.Null, global::Game.LobbyCode> __Method_joinLobbyWithoutCode = new grpc::Method<global::Game.Null, global::Game.LobbyCode>(
grpc::MethodType.Unary,
@ -73,7 +81,12 @@ namespace Game {
[grpc::BindServiceMethod(typeof(Connection), "BindService")]
public abstract partial class ConnectionBase
{
public virtual global::System.Threading.Tasks.Task<global::Game.Result> joinLobbyWithCode(global::Game.LobbyCode request, grpc::ServerCallContext context)
public virtual global::System.Threading.Tasks.Task<global::Game.UserID> connect(global::Game.Username request, grpc::ServerCallContext context)
{
throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, ""));
}
public virtual global::System.Threading.Tasks.Task<global::Game.Null> joinLobbyWithCode(global::Game.LobbyCode request, grpc::ServerCallContext context)
{
throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, ""));
}
@ -108,19 +121,35 @@ namespace Game {
{
}
public virtual global::Game.Result joinLobbyWithCode(global::Game.LobbyCode request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
public virtual global::Game.UserID connect(global::Game.Username request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
{
return connect(request, new grpc::CallOptions(headers, deadline, cancellationToken));
}
public virtual global::Game.UserID connect(global::Game.Username request, grpc::CallOptions options)
{
return CallInvoker.BlockingUnaryCall(__Method_connect, null, options, request);
}
public virtual grpc::AsyncUnaryCall<global::Game.UserID> connectAsync(global::Game.Username request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
{
return connectAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken));
}
public virtual grpc::AsyncUnaryCall<global::Game.UserID> connectAsync(global::Game.Username request, grpc::CallOptions options)
{
return CallInvoker.AsyncUnaryCall(__Method_connect, null, options, request);
}
public virtual global::Game.Null joinLobbyWithCode(global::Game.LobbyCode request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
{
return joinLobbyWithCode(request, new grpc::CallOptions(headers, deadline, cancellationToken));
}
public virtual global::Game.Result joinLobbyWithCode(global::Game.LobbyCode request, grpc::CallOptions options)
public virtual global::Game.Null joinLobbyWithCode(global::Game.LobbyCode request, grpc::CallOptions options)
{
return CallInvoker.BlockingUnaryCall(__Method_joinLobbyWithCode, null, options, request);
}
public virtual grpc::AsyncUnaryCall<global::Game.Result> joinLobbyWithCodeAsync(global::Game.LobbyCode request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
public virtual grpc::AsyncUnaryCall<global::Game.Null> joinLobbyWithCodeAsync(global::Game.LobbyCode request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
{
return joinLobbyWithCodeAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken));
}
public virtual grpc::AsyncUnaryCall<global::Game.Result> joinLobbyWithCodeAsync(global::Game.LobbyCode request, grpc::CallOptions options)
public virtual grpc::AsyncUnaryCall<global::Game.Null> joinLobbyWithCodeAsync(global::Game.LobbyCode request, grpc::CallOptions options)
{
return CallInvoker.AsyncUnaryCall(__Method_joinLobbyWithCode, null, options, request);
}
@ -152,6 +181,7 @@ namespace Game {
public static grpc::ServerServiceDefinition BindService(ConnectionBase serviceImpl)
{
return grpc::ServerServiceDefinition.CreateBuilder()
.AddMethod(__Method_connect, serviceImpl.connect)
.AddMethod(__Method_joinLobbyWithCode, serviceImpl.joinLobbyWithCode)
.AddMethod(__Method_joinLobbyWithoutCode, serviceImpl.joinLobbyWithoutCode).Build();
}
@ -162,7 +192,8 @@ namespace Game {
/// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
public static void BindService(grpc::ServiceBinderBase serviceBinder, ConnectionBase serviceImpl)
{
serviceBinder.AddMethod(__Method_joinLobbyWithCode, serviceImpl == null ? null : new grpc::UnaryServerMethod<global::Game.LobbyCode, global::Game.Result>(serviceImpl.joinLobbyWithCode));
serviceBinder.AddMethod(__Method_connect, serviceImpl == null ? null : new grpc::UnaryServerMethod<global::Game.Username, 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_joinLobbyWithoutCode, serviceImpl == null ? null : new grpc::UnaryServerMethod<global::Game.Null, global::Game.LobbyCode>(serviceImpl.joinLobbyWithoutCode));
}
@ -204,7 +235,6 @@ namespace Game {
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.Vote> __Marshaller_game_Vote = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Game.Vote.Parser));
static readonly grpc::Marshaller<global::Game.Result> __Marshaller_game_Result = grpc::Marshallers.Create(__Helper_SerializeMessage, context => __Helper_DeserializeMessage(context, global::Game.Result.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>(
@ -214,19 +244,19 @@ namespace Game {
__Marshaller_game_Null,
__Marshaller_game_Game);
static readonly grpc::Method<global::Game.Vote, global::Game.Result> __Method_vote = new grpc::Method<global::Game.Vote, global::Game.Result>(
static readonly grpc::Method<global::Game.Vote, global::Game.Null> __Method_vote = new grpc::Method<global::Game.Vote, global::Game.Null>(
grpc::MethodType.Unary,
__ServiceName,
"vote",
__Marshaller_game_Vote,
__Marshaller_game_Result);
__Marshaller_game_Null);
static readonly grpc::Method<global::Game.Null, global::Game.Result> __Method_ready = new grpc::Method<global::Game.Null, global::Game.Result>(
static readonly grpc::Method<global::Game.Null, global::Game.Null> __Method_ready = new grpc::Method<global::Game.Null, global::Game.Null>(
grpc::MethodType.Unary,
__ServiceName,
"ready",
__Marshaller_game_Null,
__Marshaller_game_Result);
__Marshaller_game_Null);
static readonly grpc::Method<global::Game.Null, global::Game.LobbyStatus> __Method_status = new grpc::Method<global::Game.Null, global::Game.LobbyStatus>(
grpc::MethodType.Unary,
@ -250,12 +280,12 @@ namespace Game {
throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, ""));
}
public virtual global::System.Threading.Tasks.Task<global::Game.Result> vote(global::Game.Vote request, grpc::ServerCallContext context)
public virtual global::System.Threading.Tasks.Task<global::Game.Null> vote(global::Game.Vote request, grpc::ServerCallContext context)
{
throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, ""));
}
public virtual global::System.Threading.Tasks.Task<global::Game.Result> ready(global::Game.Null request, grpc::ServerCallContext context)
public virtual global::System.Threading.Tasks.Task<global::Game.Null> ready(global::Game.Null request, grpc::ServerCallContext context)
{
throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, ""));
}
@ -298,35 +328,35 @@ namespace Game {
{
return CallInvoker.AsyncServerStreamingCall(__Method_getGames, null, options, request);
}
public virtual global::Game.Result vote(global::Game.Vote request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
public virtual global::Game.Null vote(global::Game.Vote request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
{
return vote(request, new grpc::CallOptions(headers, deadline, cancellationToken));
}
public virtual global::Game.Result vote(global::Game.Vote request, grpc::CallOptions options)
public virtual global::Game.Null vote(global::Game.Vote request, grpc::CallOptions options)
{
return CallInvoker.BlockingUnaryCall(__Method_vote, null, options, request);
}
public virtual grpc::AsyncUnaryCall<global::Game.Result> voteAsync(global::Game.Vote request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
public virtual grpc::AsyncUnaryCall<global::Game.Null> voteAsync(global::Game.Vote request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
{
return voteAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken));
}
public virtual grpc::AsyncUnaryCall<global::Game.Result> voteAsync(global::Game.Vote request, grpc::CallOptions options)
public virtual grpc::AsyncUnaryCall<global::Game.Null> voteAsync(global::Game.Vote request, grpc::CallOptions options)
{
return CallInvoker.AsyncUnaryCall(__Method_vote, null, options, request);
}
public virtual global::Game.Result ready(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.Null ready(global::Game.Null request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
{
return ready(request, new grpc::CallOptions(headers, deadline, cancellationToken));
}
public virtual global::Game.Result ready(global::Game.Null request, grpc::CallOptions options)
public virtual global::Game.Null ready(global::Game.Null request, grpc::CallOptions options)
{
return CallInvoker.BlockingUnaryCall(__Method_ready, null, options, request);
}
public virtual grpc::AsyncUnaryCall<global::Game.Result> readyAsync(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::AsyncUnaryCall<global::Game.Null> readyAsync(global::Game.Null request, grpc::Metadata headers = null, global::System.DateTime? deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken))
{
return readyAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken));
}
public virtual grpc::AsyncUnaryCall<global::Game.Result> readyAsync(global::Game.Null request, grpc::CallOptions options)
public virtual grpc::AsyncUnaryCall<global::Game.Null> readyAsync(global::Game.Null request, grpc::CallOptions options)
{
return CallInvoker.AsyncUnaryCall(__Method_ready, null, options, request);
}
@ -371,8 +401,8 @@ namespace Game {
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_vote, serviceImpl == null ? null : new grpc::UnaryServerMethod<global::Game.Vote, global::Game.Result>(serviceImpl.vote));
serviceBinder.AddMethod(__Method_ready, serviceImpl == null ? null : new grpc::UnaryServerMethod<global::Game.Null, global::Game.Result>(serviceImpl.ready));
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_status, serviceImpl == null ? null : new grpc::UnaryServerMethod<global::Game.Null, global::Game.LobbyStatus>(serviceImpl.status));
}

Loading…
Cancel
Save