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;
// TODO Reorganize this file
// Connection utilities to get a client_id
service Connection {
rpc name(Null) returns(Name);
rpc connect(Name) returns(UserID);
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)
service Lobby {
rpc getGames(Null) returns(stream Game);
rpc getCardImage(CardID) returns (Image);
rpc getCardImage(CardID) returns(Image);
rpc vote(Vote) returns(Null);
rpc ready (Null) returns (Null);
rpc status (Null) returns (LobbyStatus);
rpc ready(Null) returns(Null);
rpc status(Null) returns(LobbyStatus);
}
message UserID {
string id = 1;
}
message UserID { string id = 1; }
message Name {
string name = 1;
message Name { string name = 1; }
message LobbyConfig {
bool public = 1;
// repeated uint32 allowed_games = 2;
}
message Null {}
message CardID {
uint64 gameId = 1;
uint32 gameId = 1;
string cardId = 2;
}
message Image {
bytes content = 1;
}
message Image { bytes content = 1; }
message LobbyCode { uint32 code = 1; }
@ -44,18 +46,18 @@ message Game {
string name = 1;
string version = 2;
repeated string authors = 3;
uint64 id = 4;
uint32 id = 4;
}
message Vote { uint64 id = 1; }
message LobbyStatus {
repeated Vote votes = 1;
repeated Player ready = 2;
bool isStarting = 3;
repeated Vote votes = 1;
repeated Player ready = 2;
bool isStarting = 3;
}
message Player {
string name = 1;
uint64 id = 2;
string name = 1;
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 tokio::stream::StreamExt;
use sqlx::{
pool::PoolConnection, prelude::*, query_as, query_file_unchecked, query_unchecked, FromRow,
SqliteConnection, SqlitePool,
};
// use tokio::stream::StreamExt;
pub mod types;
@ -39,8 +42,7 @@ pub struct DbConnection {
use uuid::Uuid;
// TODO: return Results intead of crashing
// FIXME: return Results intead of crashing
impl DbConnection {
fn new(conn: PoolConnection<SqliteConnection>) -> Self {
Self { conn }
@ -60,19 +62,20 @@ impl DbConnection {
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 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 {
pub async fn create_lobby(&mut self, public: bool) -> u32 {
let id = rand::random();
self.conn
.execute(query_unchecked!(
"INSERT INTO Lobbies(id) VALUES(?)",
id as i32
"INSERT INTO Lobbies(id, public) VALUES(?, ?)",
id as i32,
public
))
.await
.unwrap(); // Server crashes if ids collide
@ -93,5 +96,11 @@ impl DbConnection {
pub async fn close(self) {
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 {
#[allow(unused)] // TODO remove
piles: HashMap<String, Pile>,
#[allow(unused)] // TODO remove
player_piles: Vec<HashMap<String, Pile>>,
}

122
server/src/grpc.rs

@ -4,17 +4,19 @@ use log::info;
use std::sync::Arc;
#[allow(non_camel_case_types)]
mod game;
use game::connection_server::{Connection, ConnectionServer};
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;
pub struct ConnectionService {
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]
@ -36,39 +38,71 @@ impl Connection for ConnectionService {
) -> 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")
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{}))
Ok(Response::new(Null {}))
}
async fn join_lobby_without_code(
async fn create_lobby(
&self,
request: Request<Null>,
request: Request<LobbyConfig>,
) -> 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")
client_id::Error::MalformedUuid => Status::failed_precondition("malformed client_id"),
})?;
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.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,
_request: Request<Null>,
) -> Result<Response<game::Name>, Status> {
Ok(Response::new(game::Name {name: self.properties.name.clone() }))
) -> Result<Response<Self::getPublicLobbiesStream>, Status> {
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;
pub struct LobbyService {
@ -78,55 +112,51 @@ pub struct LobbyService {
#[tonic::async_trait]
impl Lobby for LobbyService {
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 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> {
async fn get_card_image(
&self,
request: tonic::Request<CardId>,
) -> Result<tonic::Response<Image>, tonic::Status> {
let id = request.into_inner();
let game = &self.games.as_ref()[id.game_id as usize];
let card = game.get_card_path(&id.card_id);
let mut buffer = Vec::new();
image::open(&card).expect(&format!("Error loading the image in {:?}", card)).write_to(&mut buffer, image::ImageOutputFormat::Png).unwrap();
Ok(Response::new(Image {content: buffer}))
image::open(&card)
.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(
&self,
request: Request<game::Vote>,
) -> Result<Response<Null>, Status> {
async fn vote(&self, _request: Request<game::Vote>) -> Result<Response<Null>, Status> {
todo!()
}
async fn ready(
&self,
request: Request<Null>,
) -> Result<Response<Null>, Status> {
async fn ready(&self, _request: Request<Null>) -> Result<Response<Null>, Status> {
todo!()
}
async fn status(
&self,
request: Request<Null>,
) -> Result<Response<game::LobbyStatus>, Status> {
async fn status(&self, _request: Request<Null>) -> Result<Response<game::LobbyStatus>, Status> {
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 properties = Arc::new(properties);
let connection = ConnectionService { conn: arc.clone(), properties };
let lobby = LobbyService {conn: arc.clone(), games: Arc::new(games)};
let games = Arc::new(games);
let connection = ConnectionService {
conn: arc.clone(),
properties,
games: games.clone(),
};
let lobby = LobbyService {
conn: arc.clone(),
games,
};
Server::builder()
.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 {
pub fn get(
metadata: &tonic::metadata::MetadataMap,
) -> Result<uuid::Uuid, Error> {
pub fn get(metadata: &tonic::metadata::MetadataMap) -> Result<uuid::Uuid, Error> {
metadata
.get("client_id")
.ok_or(Error::NotSet)

155
server/src/grpc/game.rs

@ -9,11 +9,17 @@ pub struct Name {
pub name: std::string::String,
}
#[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 {}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CardId {
#[prost(uint64, tag = "1")]
pub game_id: u64,
#[prost(uint32, tag = "1")]
pub game_id: u32,
#[prost(string, tag = "2")]
pub card_id: std::string::String,
}
@ -35,8 +41,8 @@ pub struct Game {
pub version: std::string::String,
#[prost(string, repeated, tag = "3")]
pub authors: ::std::vec::Vec<std::string::String>,
#[prost(uint64, tag = "4")]
pub id: u64,
#[prost(uint32, tag = "4")]
pub id: u32,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Vote {
@ -56,8 +62,8 @@ pub struct LobbyStatus {
pub struct Player {
#[prost(string, tag = "1")]
pub name: std::string::String,
#[prost(uint64, tag = "2")]
pub id: u64,
#[prost(uint32, tag = "2")]
pub id: u32,
}
#[doc = r" Generated server implementations."]
pub mod connection_server {
@ -78,10 +84,28 @@ pub mod connection_server {
&self,
request: tonic::Request<super::LobbyCode>,
) -> Result<tonic::Response<super::Null>, tonic::Status>;
async fn join_lobby_without_code(
async fn create_lobby(
&self,
request: tonic::Request<super::Null>,
request: tonic::Request<super::LobbyConfig>,
) -> 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"]
#[derive(Debug)]
@ -203,16 +227,18 @@ pub mod connection_server {
};
Box::pin(fut)
}
"/game.Connection/joinLobbyWithoutCode" => {
"/game.Connection/createLobby" => {
#[allow(non_camel_case_types)]
struct joinLobbyWithoutCodeSvc<T: Connection>(pub Arc<T>);
impl<T: Connection> tonic::server::UnaryService<super::Null> for joinLobbyWithoutCodeSvc<T> {
struct createLobbySvc<T: Connection>(pub Arc<T>);
impl<T: Connection> tonic::server::UnaryService<super::LobbyConfig> for createLobbySvc<T> {
type Response = super::LobbyCode;
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 fut =
async move { (*inner).join_lobby_without_code(request).await };
let fut = async move { (*inner).create_lobby(request).await };
Box::pin(fut)
}
}
@ -220,7 +246,7 @@ pub mod connection_server {
let fut = async move {
let interceptor = inner.1.clone();
let inner = inner.0;
let method = joinLobbyWithoutCodeSvc(inner);
let method = createLobbySvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = if let Some(interceptor) = interceptor {
tonic::server::Grpc::with_interceptor(codec, interceptor)
@ -232,6 +258,66 @@ pub mod connection_server {
};
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 {
Ok(http::Response::builder()
.status(200)
@ -269,15 +355,6 @@ pub mod lobby_server {
#[doc = "Generated trait containing gRPC methods that should be implemented for use with LobbyServer."]
#[async_trait]
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(
&self,
request: tonic::Request<super::CardId>,
@ -328,36 +405,6 @@ pub mod lobby_server {
fn call(&mut self, req: http::Request<B>) -> Self::Future {
let inner = self.inner.clone();
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" => {
#[allow(non_camel_case_types)]
struct getCardImageSvc<T: Lobby>(pub Arc<T>);

58
server/src/logger/color_message.rs

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

3
server/src/setup.sql

@ -11,7 +11,8 @@ CREATE TABLE Users (
);
CREATE TABLE Lobbies (
ID INT NOT NULL UNIQUE PRIMARY KEY
ID INT NOT NULL UNIQUE PRIMARY KEY,
Public BOOLEAN DEFAULT false
);
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) });
}
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);
}
@ -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()
{
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>();
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
guid: d503170ae4972ff3db5f76af29a9d5d0
guid: b147307868234ce40afbc5ba5dc4a020
MonoImporter:
externalObjects: {}
serializedVersion: 2

11
unity/Assets/Scripts/MainMenuController.cs

@ -121,7 +121,7 @@ public class MainMenuController : MonoBehaviour {
if (conn != null) {
var lobby = conn.GetLobby();
if (lobby == null) {
lobby = conn.CreateLobby();
lobby = conn.CreateLobby(true);
mainMenu.SetActive(false);
serverMenu.SetActive(false);
lobbyMenu.SetActive(true);
@ -151,6 +151,13 @@ public class MainMenuController : MonoBehaviour {
DestroyImmediate(serverScroll.transform.GetChild(i).gameObject);
}
// 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++) {
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);
@ -174,7 +181,9 @@ public class MainMenuController : MonoBehaviour {
gameGO.GetComponentsInChildren<Text>()[2].text = string.Join(", ", game.Authors);
gameGO.gameObject.SetActive(true);
}
// conn.Close();
}
lobbyMenu.GetComponentInChildren<Scrollable>().Reload();
}
}

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

@ -25,28 +25,30 @@ namespace Game {
byte[] descriptorData = global::System.Convert.FromBase64String(
string.Concat(
"CgpnYW1lLnByb3RvEgRnYW1lIhQKBlVzZXJJRBIKCgJpZBgBIAEoCSIUCgRO",
"YW1lEgwKBG5hbWUYASABKAkiBgoETnVsbCIoCgZDYXJkSUQSDgoGZ2FtZUlk",
"GAEgASgEEg4KBmNhcmRJZBgCIAEoCSIYCgVJbWFnZRIPCgdjb250ZW50GAEg",
"ASgMIhkKCUxvYmJ5Q29kZRIMCgRjb2RlGAEgASgNIkIKBEdhbWUSDAoEbmFt",
"ZRgBIAEoCRIPCgd2ZXJzaW9uGAIgASgJEg8KB2F1dGhvcnMYAyADKAkSCgoC",
"aWQYBCABKAQiEgoEVm90ZRIKCgJpZBgBIAEoBCJZCgtMb2JieVN0YXR1cxIZ",
"CgV2b3RlcxgBIAMoCzIKLmdhbWUuVm90ZRIbCgVyZWFkeRgCIAMoCzIMLmdh",
"bWUuUGxheWVyEhIKCmlzU3RhcnRpbmcYAyABKAgiIgoGUGxheWVyEgwKBG5h",
"bWUYASABKAkSCgoCaWQYAiABKAQyuAEKCkNvbm5lY3Rpb24SHgoEbmFtZRIK",
"LmdhbWUuTnVsbBoKLmdhbWUuTmFtZRIjCgdjb25uZWN0EgouZ2FtZS5OYW1l",
"GgwuZ2FtZS5Vc2VySUQSMAoRam9pbkxvYmJ5V2l0aENvZGUSDy5nYW1lLkxv",
"YmJ5Q29kZRoKLmdhbWUuTnVsbBIzChRqb2luTG9iYnlXaXRob3V0Q29kZRIK",
"LmdhbWUuTnVsbBoPLmdhbWUuTG9iYnlDb2RlMsIBCgVMb2JieRIkCghnZXRH",
"YW1lcxIKLmdhbWUuTnVsbBoKLmdhbWUuR2FtZTABEikKDGdldENhcmRJbWFn",
"ZRIMLmdhbWUuQ2FyZElEGgsuZ2FtZS5JbWFnZRIeCgR2b3RlEgouZ2FtZS5W",
"b3RlGgouZ2FtZS5OdWxsEh8KBXJlYWR5EgouZ2FtZS5OdWxsGgouZ2FtZS5O",
"dWxsEicKBnN0YXR1cxIKLmdhbWUuTnVsbBoRLmdhbWUuTG9iYnlTdGF0dXNi",
"BnByb3RvMw=="));
"YW1lEgwKBG5hbWUYASABKAkiHQoLTG9iYnlDb25maWcSDgoGcHVibGljGAEg",
"ASgIIgYKBE51bGwiKAoGQ2FyZElEEg4KBmdhbWVJZBgBIAEoDRIOCgZjYXJk",
"SWQYAiABKAkiGAoFSW1hZ2USDwoHY29udGVudBgBIAEoDCIZCglMb2JieUNv",
"ZGUSDAoEY29kZRgBIAEoDSJCCgRHYW1lEgwKBG5hbWUYASABKAkSDwoHdmVy",
"c2lvbhgCIAEoCRIPCgdhdXRob3JzGAMgAygJEgoKAmlkGAQgASgNIhIKBFZv",
"dGUSCgoCaWQYASABKAQiWQoLTG9iYnlTdGF0dXMSGQoFdm90ZXMYASADKAsy",
"Ci5nYW1lLlZvdGUSGwoFcmVhZHkYAiADKAsyDC5nYW1lLlBsYXllchISCgpp",
"c1N0YXJ0aW5nGAMgASgIIiIKBlBsYXllchIMCgRuYW1lGAEgASgJEgoKAmlk",
"GAIgASgNMo8CCgpDb25uZWN0aW9uEh4KBG5hbWUSCi5nYW1lLk51bGwaCi5n",
"YW1lLk5hbWUSIwoHY29ubmVjdBIKLmdhbWUuTmFtZRoMLmdhbWUuVXNlcklE",
"EjAKEWpvaW5Mb2JieVdpdGhDb2RlEg8uZ2FtZS5Mb2JieUNvZGUaCi5nYW1l",
"Lk51bGwSMQoLY3JlYXRlTG9iYnkSES5nYW1lLkxvYmJ5Q29uZmlnGg8uZ2Ft",
"ZS5Mb2JieUNvZGUSJAoIZ2V0R2FtZXMSCi5nYW1lLk51bGwaCi5nYW1lLkdh",
"bWUwARIxChBnZXRQdWJsaWNMb2JiaWVzEgouZ2FtZS5OdWxsGg8uZ2FtZS5M",
"b2JieUNvZGUwATKcAQoFTG9iYnkSKQoMZ2V0Q2FyZEltYWdlEgwuZ2FtZS5D",
"YXJkSUQaCy5nYW1lLkltYWdlEh4KBHZvdGUSCi5nYW1lLlZvdGUaCi5nYW1l",
"Lk51bGwSHwoFcmVhZHkSCi5nYW1lLk51bGwaCi5nYW1lLk51bGwSJwoGc3Rh",
"dHVzEgouZ2FtZS5OdWxsGhEuZ2FtZS5Mb2JieVN0YXR1c2IGcHJvdG8z"));
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.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.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),
@ -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>
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
, pb::IBufferMessage
@ -417,7 +594,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]
@ -553,7 +730,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]
@ -582,9 +759,9 @@ namespace Game {
/// <summary>Field number for the "gameId" field.</summary>
public const int GameIdFieldNumber = 1;
private ulong gameId_;
private uint gameId_;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public ulong GameId {
public uint GameId {
get { return gameId_; }
set {
gameId_ = value;
@ -623,7 +800,7 @@ namespace Game {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override int GetHashCode() {
int hash = 1;
if (GameId != 0UL) hash ^= GameId.GetHashCode();
if (GameId != 0) hash ^= GameId.GetHashCode();
if (CardId.Length != 0) hash ^= CardId.GetHashCode();
if (_unknownFields != null) {
hash ^= _unknownFields.GetHashCode();
@ -641,9 +818,9 @@ namespace Game {
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
output.WriteRawMessage(this);
#else
if (GameId != 0UL) {
if (GameId != 0) {
output.WriteRawTag(8);
output.WriteUInt64(GameId);
output.WriteUInt32(GameId);
}
if (CardId.Length != 0) {
output.WriteRawTag(18);
@ -658,9 +835,9 @@ namespace Game {
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) {
if (GameId != 0UL) {
if (GameId != 0) {
output.WriteRawTag(8);
output.WriteUInt64(GameId);
output.WriteUInt32(GameId);
}
if (CardId.Length != 0) {
output.WriteRawTag(18);
@ -675,8 +852,8 @@ namespace Game {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int CalculateSize() {
int size = 0;
if (GameId != 0UL) {
size += 1 + pb::CodedOutputStream.ComputeUInt64Size(GameId);
if (GameId != 0) {
size += 1 + pb::CodedOutputStream.ComputeUInt32Size(GameId);
}
if (CardId.Length != 0) {
size += 1 + pb::CodedOutputStream.ComputeStringSize(CardId);
@ -692,7 +869,7 @@ namespace Game {
if (other == null) {
return;
}
if (other.GameId != 0UL) {
if (other.GameId != 0) {
GameId = other.GameId;
}
if (other.CardId.Length != 0) {
@ -713,7 +890,7 @@ namespace Game {
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 8: {
GameId = input.ReadUInt64();
GameId = input.ReadUInt32();
break;
}
case 18: {
@ -735,7 +912,7 @@ namespace Game {
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input);
break;
case 8: {
GameId = input.ReadUInt64();
GameId = input.ReadUInt32();
break;
}
case 18: {
@ -761,7 +938,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]
@ -933,7 +1110,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]
@ -1105,7 +1282,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]
@ -1168,9 +1345,9 @@ namespace Game {
/// <summary>Field number for the "id" field.</summary>
public const int IdFieldNumber = 4;
private ulong id_;
private uint id_;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public ulong Id {
public uint Id {
get { return id_; }
set {
id_ = value;
@ -1203,7 +1380,7 @@ namespace Game {
if (Name.Length != 0) hash ^= Name.GetHashCode();
if (Version.Length != 0) hash ^= Version.GetHashCode();
hash ^= authors_.GetHashCode();
if (Id != 0UL) hash ^= Id.GetHashCode();
if (Id != 0) hash ^= Id.GetHashCode();
if (_unknownFields != null) {
hash ^= _unknownFields.GetHashCode();
}
@ -1229,9 +1406,9 @@ namespace Game {
output.WriteString(Version);
}
authors_.WriteTo(output, _repeated_authors_codec);
if (Id != 0UL) {
if (Id != 0) {
output.WriteRawTag(32);
output.WriteUInt64(Id);
output.WriteUInt32(Id);
}
if (_unknownFields != null) {
_unknownFields.WriteTo(output);
@ -1251,9 +1428,9 @@ namespace Game {
output.WriteString(Version);
}
authors_.WriteTo(ref output, _repeated_authors_codec);
if (Id != 0UL) {
if (Id != 0) {
output.WriteRawTag(32);
output.WriteUInt64(Id);
output.WriteUInt32(Id);
}
if (_unknownFields != null) {
_unknownFields.WriteTo(ref output);
@ -1271,8 +1448,8 @@ namespace Game {
size += 1 + pb::CodedOutputStream.ComputeStringSize(Version);
}
size += authors_.CalculateSize(_repeated_authors_codec);
if (Id != 0UL) {
size += 1 + pb::CodedOutputStream.ComputeUInt64Size(Id);
if (Id != 0) {
size += 1 + pb::CodedOutputStream.ComputeUInt32Size(Id);
}
if (_unknownFields != null) {
size += _unknownFields.CalculateSize();
@ -1292,7 +1469,7 @@ namespace Game {
Version = other.Version;
}
authors_.Add(other.authors_);
if (other.Id != 0UL) {
if (other.Id != 0) {
Id = other.Id;
}
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
@ -1322,7 +1499,7 @@ namespace Game {
break;
}
case 32: {
Id = input.ReadUInt64();
Id = input.ReadUInt32();
break;
}
}
@ -1352,7 +1529,7 @@ namespace Game {
break;
}
case 32: {
Id = input.ReadUInt64();
Id = input.ReadUInt32();
break;
}
}
@ -1374,7 +1551,7 @@ namespace Game {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
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]
@ -1546,7 +1723,7 @@ namespace Game {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
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]
@ -1768,7 +1945,7 @@ namespace Game {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
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]
@ -1808,9 +1985,9 @@ namespace Game {
/// <summary>Field number for the "id" field.</summary>
public const int IdFieldNumber = 2;
private ulong id_;
private uint id_;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public ulong Id {
public uint Id {
get { return id_; }
set {
id_ = value;
@ -1839,7 +2016,7 @@ namespace Game {
public override int GetHashCode() {
int hash = 1;
if (Name.Length != 0) hash ^= Name.GetHashCode();
if (Id != 0UL) hash ^= Id.GetHashCode();
if (Id != 0) hash ^= Id.GetHashCode();
if (_unknownFields != null) {
hash ^= _unknownFields.GetHashCode();
}
@ -1860,9 +2037,9 @@ namespace Game {
output.WriteRawTag(10);
output.WriteString(Name);
}
if (Id != 0UL) {
if (Id != 0) {
output.WriteRawTag(16);
output.WriteUInt64(Id);
output.WriteUInt32(Id);
}
if (_unknownFields != null) {
_unknownFields.WriteTo(output);
@ -1877,9 +2054,9 @@ namespace Game {
output.WriteRawTag(10);
output.WriteString(Name);
}
if (Id != 0UL) {
if (Id != 0) {
output.WriteRawTag(16);
output.WriteUInt64(Id);
output.WriteUInt32(Id);
}
if (_unknownFields != null) {
_unknownFields.WriteTo(ref output);
@ -1893,8 +2070,8 @@ namespace Game {
if (Name.Length != 0) {
size += 1 + pb::CodedOutputStream.ComputeStringSize(Name);
}
if (Id != 0UL) {
size += 1 + pb::CodedOutputStream.ComputeUInt64Size(Id);
if (Id != 0) {
size += 1 + pb::CodedOutputStream.ComputeUInt32Size(Id);
}
if (_unknownFields != null) {
size += _unknownFields.CalculateSize();
@ -1910,7 +2087,7 @@ namespace Game {
if (other.Name.Length != 0) {
Name = other.Name;
}
if (other.Id != 0UL) {
if (other.Id != 0) {
Id = other.Id;
}
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
@ -1932,7 +2109,7 @@ namespace Game {
break;
}
case 16: {
Id = input.ReadUInt64();
Id = input.ReadUInt32();
break;
}
}
@ -1954,7 +2131,7 @@ namespace Game {
break;
}
case 16: {
Id = input.ReadUInt64();
Id = input.ReadUInt32();
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.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.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>(
grpc::MethodType.Unary,
@ -71,10 +73,24 @@ namespace Game {
__Marshaller_game_LobbyCode,
__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,
__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_LobbyCode);
@ -103,7 +119,17 @@ namespace Game {
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, ""));
}
@ -181,21 +207,37 @@ namespace Game {
{
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>
protected override ConnectionClient NewInstance(ClientBaseConfiguration configuration)
@ -212,7 +254,9 @@ namespace Game {
.AddMethod(__Method_name, serviceImpl.name)
.AddMethod(__Method_connect, serviceImpl.connect)
.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.
@ -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_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_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());
}
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.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.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::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>(
grpc::MethodType.Unary,
__ServiceName,
@ -317,11 +355,6 @@ namespace Game {
[grpc::BindServiceMethod(typeof(Lobby), "BindService")]
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)
{
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))
{
return getCardImage(request, new grpc::CallOptions(headers, deadline, cancellationToken));
@ -451,7 +476,6 @@ namespace Game {
public static grpc::ServerServiceDefinition BindService(LobbyBase serviceImpl)
{
return grpc::ServerServiceDefinition.CreateBuilder()
.AddMethod(__Method_getGames, serviceImpl.getGames)
.AddMethod(__Method_getCardImage, serviceImpl.getCardImage)
.AddMethod(__Method_vote, serviceImpl.vote)
.AddMethod(__Method_ready, serviceImpl.ready)
@ -464,7 +488,6 @@ namespace Game {
/// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
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_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));

Loading…
Cancel
Save