Skip to content

Commit

Permalink
repositionings
Browse files Browse the repository at this point in the history
  • Loading branch information
2ne1ugly committed Feb 15, 2020
1 parent 4e7bcf0 commit ec4c61f
Show file tree
Hide file tree
Showing 14 changed files with 115 additions and 158 deletions.
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "lib/lgrpc/proto"]
path = lib/lgrpc/proto
[submodule "proto"]
path = proto
url = https://github.com/2ne1ugly/Ognam-Layton-Protobuf.git
1 change: 1 addition & 0 deletions Setup.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
protoc --proto_path=proto --elixir_out=lib layton.proto
2 changes: 2 additions & 0 deletions Setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
protoc --elixir_out=plugins=grpc:lib layton.proto
10 changes: 10 additions & 0 deletions lib/layton.pb.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
defmodule Lgrpc.ResultCode do
@moduledoc false
use Protobuf, enum: true, syntax: :proto3

@type t :: integer | :RC_ERROR | :RC_SUCCESS | :RC_FAIL

field :RC_ERROR, 0
field :RC_SUCCESS, 1
field :RC_FAIL, 2
end
13 changes: 12 additions & 1 deletion lib/layton/endpoint.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
defmodule Layton.Endpoint do
# Client Service Endpoint
defmodule Layton.Client.Endpoint do
use GRPC.Endpoint

GRPC.Logger

intercept(GRPC.Logger.Server)
run(Layton.Lgrpc.Server)
end

# Session Service Endpoint
defmodule Layton.GameServer.Endpoint do
use GRPC.Endpoint

GRPC.Logger
Expand Down
47 changes: 0 additions & 47 deletions lib/layton/server/server.ex

This file was deleted.

47 changes: 47 additions & 0 deletions lib/layton/service/client.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# defmodule Layton.Client.Service do
# use GRPC.Server, service: Lgrpc.Client.Service

# ##
# ## IDENTITY
# ##
# def create_account(request, _stream) do
# changeset = Layton.Schema.Account.changeset(request)

# case Layton.Repo.insert(changeset) do
# {:ok, _} -> Lgrpc.Result.new(result_code: :ERC_SUCCESS)
# {:error, _} -> Lgrpc.Result.new(result_code: :ERC_FAIL)
# end
# end

# def login(request, _stream) do
# # Check If it's inside the database and return true/false
# case Layton.Repo.get_by(Layton.Schema.Account, Map.from_struct(request)) do
# nil -> Lgrpc.Result.new(result_code: :ERC_FAIL)
# _account -> Lgrpc.Result.new(result_code: :ERC_SUCCESS)
# end
# end

# ##
# ## Session
# ##
# def create_session(request, _stream) do
# session = %Layton.Types.Session{session_name: request.session_name}

# case Layton.Lgrpc.Server.Session.create_session(session) do
# :ok -> Lgrpc.Result.new(result_code: :ERC_SUCCESS)
# {:error, :already_exists} -> Lgrpc.Result.new(result_code: :ERC_FAIL)
# end
# end

# def find_sessions(_request, _stream) do
# Lgrpc.FindSessionsResponse.new(result_code: :ERC_SUCCESS, sessions: Layton.Lgrpc.Server.Session.find_sessions())
# end

# def join_session(request, _stream) do
# Lgrpc.Result.new(result_code: :ERC_ERROR)
# end

# def start_session(request, _stream) do
# Lgrpc.Result.new(result_code: :ERC_ERROR)
# end
# end
3 changes: 3 additions & 0 deletions lib/layton/service/game_server.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# defmodule Layton.GameServer.Service do
# use GRPC.Server, service: Lgrpc.GameServer.Service
# end
Empty file.
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
defmodule Layton.Lgrpc.Server.Session do
defmodule Layton.System.LobbySessionServer do
@moduledoc """
Server that holds current session informations
Server that keeps track on list of lobbies (including on-going ones.)
"""
use GenServer
alias __MODULE__

defstruct session_map: %{}

#
# Client Functions
#

def create_session(session) do
GenServer.call(__MODULE__, {:create_session, session})
end
Expand All @@ -14,13 +19,28 @@ defmodule Layton.Lgrpc.Server.Session do
GenServer.call(__MODULE__, :find_sessions)
end

def start_session() do
GenServer.call(__MODULE__, :start_session)
end

def join_session() do
GenServer.call(__MODULE__, :join_session)
end

def leave_session() do
GenServer.call(__MODULE__, :leave_session)
end

#
# Bindings
#
def start_link(_args) do
GenServer.start(__MODULE__, [], name: __MODULE__)
end

@impl true
def init([]) do
{:ok, %Layton.Lgrpc.Server.Session{}}
{:ok, %SessionServer{}}
end

@impl true
Expand Down
85 changes: 0 additions & 85 deletions lib/lgrpc/layton.pb.ex

This file was deleted.

1 change: 0 additions & 1 deletion lib/lgrpc/proto
Submodule proto deleted from 88b9aa
33 changes: 14 additions & 19 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
%{
"connection": {:hex, :connection, "1.0.4", "a1cae72211f0eef17705aaededacac3eb30e6625b04a6117c1b2db6ace7d5976", [:mix], [], "hexpm"},
"cowboy": {:hex, :cowboy, "2.7.0", "91ed100138a764355f43316b1d23d7ff6bdb0de4ea618cb5d8677c93a7a2f115", [:rebar3], [{:cowlib, "~> 2.8.0", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "~> 1.7.1", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm"},
"cowlib": {:hex, :grpc_cowlib, "2.8.1", "ddaf77f3b89bd8e6c76df67b28a4b069688eef91c0c497a246cf9bfcdf87f7d3", [:rebar3], [], "hexpm"},
"db_connection": {:hex, :db_connection, "2.2.0", "e923e88887cd60f9891fd324ac5e0290954511d090553c415fbf54be4c57ee63", [:mix], [{:connection, "~> 1.0.2", [hex: :connection, repo: "hexpm", optional: false]}], "hexpm"},
"decimal": {:hex, :decimal, "1.8.1", "a4ef3f5f3428bdbc0d35374029ffcf4ede8533536fa79896dd450168d9acdf3c", [:mix], [], "hexpm"},
"ecto": {:hex, :ecto, "3.3.1", "82ab74298065bf0c64ca299f6c6785e68ea5d6b980883ee80b044499df35aba1", [:mix], [{:decimal, "~> 1.6", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm"},
"ecto_enum": {:hex, :ecto_enum, "1.4.0", "d14b00e04b974afc69c251632d1e49594d899067ee2b376277efd8233027aec8", [:mix], [{:ecto, ">= 3.0.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:ecto_sql, "> 3.0.0", [hex: :ecto_sql, repo: "hexpm", optional: false]}, {:mariaex, ">= 0.0.0", [hex: :mariaex, repo: "hexpm", optional: true]}, {:postgrex, ">= 0.0.0", [hex: :postgrex, repo: "hexpm", optional: true]}], "hexpm"},
"ecto_sql": {:hex, :ecto_sql, "3.3.2", "92804e0de69bb63e621273c3492252cb08a29475c05d40eeb6f41ad2d483cfd3", [:mix], [{:db_connection, "~> 2.2", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.3", [hex: :ecto, repo: "hexpm", optional: false]}, {:myxql, "~> 0.3.0", [hex: :myxql, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.15.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm"},
"google_protos": {:hex, :google_protos, "0.1.0", "c6b9e12092d17571b093d4156d004494ca143b65dbbcbfc3ffff463ea03467c0", [:mix], [{:protobuf, "~> 0.5", [hex: :protobuf, repo: "hexpm", optional: false]}], "hexpm"},
"grpc": {:git, "https://github.com/elixir-grpc/grpc.git", "54228be54acb217e2de285bb144b8a846cd86445", []},
"gun": {:hex, :grpc_gun, "2.0.0", "f99678a2ab975e74372a756c86ec30a8384d3ac8a8b86c7ed6243ef4e61d2729", [:rebar3], [{:cowlib, "~> 2.8.0", [hex: :cowlib, repo: "hexpm", optional: false]}], "hexpm"},
"connection": {:hex, :connection, "1.0.4", "a1cae72211f0eef17705aaededacac3eb30e6625b04a6117c1b2db6ace7d5976", [:mix], [], "hexpm", "4a0850c9be22a43af9920a71ab17c051f5f7d45c209e40269a1938832510e4d9"},
"cowboy": {:hex, :cowboy, "2.7.0", "91ed100138a764355f43316b1d23d7ff6bdb0de4ea618cb5d8677c93a7a2f115", [:rebar3], [{:cowlib, "~> 2.8.0", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "~> 1.7.1", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "04fd8c6a39edc6aaa9c26123009200fc61f92a3a94f3178c527b70b767c6e605"},
"cowlib": {:hex, :grpc_cowlib, "2.8.1", "ddaf77f3b89bd8e6c76df67b28a4b069688eef91c0c497a246cf9bfcdf87f7d3", [:rebar3], [], "hexpm", "0366f82719d24af4ce45a6591f52a7fc859785823fde4cd84e0dc45119b5ed89"},
"db_connection": {:hex, :db_connection, "2.2.1", "caee17725495f5129cb7faebde001dc4406796f12a62b8949f4ac69315080566", [:mix], [{:connection, "~> 1.0.2", [hex: :connection, repo: "hexpm", optional: false]}], "hexpm", "2b02ece62d9f983fcd40954e443b7d9e6589664380e5546b2b9b523cd0fb59e1"},
"decimal": {:hex, :decimal, "1.8.1", "a4ef3f5f3428bdbc0d35374029ffcf4ede8533536fa79896dd450168d9acdf3c", [:mix], [], "hexpm", "3cb154b00225ac687f6cbd4acc4b7960027c757a5152b369923ead9ddbca7aec"},
"ecto": {:hex, :ecto, "3.3.3", "0830bf3aebcbf3d8c1a1811cd581773b6866886c012f52c0f027031fa96a0b53", [:mix], [{:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "12e368e3c2a2938d7776defaabdae40e82900fc4d8d66120ec1e01dfd8b93c3a"},
"ecto_sql": {:hex, :ecto_sql, "3.3.4", "aa18af12eb875fbcda2f75e608b3bd534ebf020fc4f6448e4672fcdcbb081244", [:mix], [{:db_connection, "~> 2.2", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.4 or ~> 3.3.3", [hex: :ecto, repo: "hexpm", optional: false]}, {:myxql, "~> 0.3.0", [hex: :myxql, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.15.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "5eccbdbf92e3c6f213007a82d5dbba4cd9bb659d1a21331f89f408e4c0efd7a8"},
"google_protos": {:hex, :google_protos, "0.1.0", "c6b9e12092d17571b093d4156d004494ca143b65dbbcbfc3ffff463ea03467c0", [:mix], [{:protobuf, "~> 0.5", [hex: :protobuf, repo: "hexpm", optional: false]}], "hexpm", "ff5564525f89d2638a4cfa9fb4d31e9ee9d9d7cb937b3e8a95f558440c039e1b"},
"grpc": {:git, "https://github.com/elixir-grpc/grpc.git", "485349728782a6e8e83fb3eab745860737eeef6f", []},
"gun": {:hex, :grpc_gun, "2.0.0", "f99678a2ab975e74372a756c86ec30a8384d3ac8a8b86c7ed6243ef4e61d2729", [:rebar3], [{:cowlib, "~> 2.8.0", [hex: :cowlib, repo: "hexpm", optional: false]}], "hexpm", "03dbbca1a9c604a0267a40ea1d69986225091acb822de0b2dbea21d5815e410b"},
"mime": {:hex, :mime, "1.3.1", "30ce04ab3175b6ad0bdce0035cba77bba68b813d523d1aac73d9781b4d193cf8", [:mix], [], "hexpm"},
"plug": {:hex, :plug, "1.8.3", "12d5f9796dc72e8ac9614e94bda5e51c4c028d0d428e9297650d09e15a684478", [:mix], [{:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: true]}], "hexpm"},
"plug_cowboy": {:hex, :plug_cowboy, "2.1.1", "a196e4f428d7f5d6dba5ded314cc55cd0fbddf1110af620f75c0190e77844b33", [:mix], [{:cowboy, "~> 2.5", [hex: :cowboy, repo: "hexpm", optional: false]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"},
"plug_crypto": {:hex, :plug_crypto, "1.0.0", "18e49317d3fa343f24620ed22795ec29d4a5e602d52d1513ccea0b07d8ea7d4d", [:mix], [], "hexpm"},
"poison": {:hex, :poison, "4.0.1", "bcb755a16fac91cad79bfe9fc3585bb07b9331e50cfe3420a24bcc2d735709ae", [:mix], [], "hexpm"},
"postgrex": {:hex, :postgrex, "0.15.3", "5806baa8a19a68c4d07c7a624ccdb9b57e89cbc573f1b98099e3741214746ae4", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.5", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm"},
"protobuf": {:hex, :protobuf, "0.7.1", "7d1b9f7d9ecb32eccd96b0c58572de4d1c09e9e3bc414e4cb15c2dce7013f195", [:mix], [], "hexpm"},
"ranch": {:hex, :ranch, "1.7.1", "6b1fab51b49196860b733a49c07604465a47bdb78aa10c1c16a3d199f7f8c881", [:rebar3], [], "hexpm"},
"telemetry": {:hex, :telemetry, "0.4.1", "ae2718484892448a24470e6aa341bc847c3277bfb8d4e9289f7474d752c09c7f", [:rebar3], [], "hexpm"},
"postgrex": {:hex, :postgrex, "0.15.3", "5806baa8a19a68c4d07c7a624ccdb9b57e89cbc573f1b98099e3741214746ae4", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.5", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "4737ce62a31747b4c63c12b20c62307e51bb4fcd730ca0c32c280991e0606c90"},
"protobuf": {:hex, :protobuf, "0.7.1", "7d1b9f7d9ecb32eccd96b0c58572de4d1c09e9e3bc414e4cb15c2dce7013f195", [:mix], [], "hexpm", "6eff7a5287963719521c82e5d5b4583fd1d7cdd89ad129f0ea7d503a50a4d13f"},
"ranch": {:hex, :ranch, "1.7.1", "6b1fab51b49196860b733a49c07604465a47bdb78aa10c1c16a3d199f7f8c881", [:rebar3], [], "hexpm", "451d8527787df716d99dc36162fca05934915db0b6141bbdac2ea8d3c7afc7d7"},
"telemetry": {:hex, :telemetry, "0.4.1", "ae2718484892448a24470e6aa341bc847c3277bfb8d4e9289f7474d752c09c7f", [:rebar3], [], "hexpm", "4738382e36a0a9a2b6e25d67c960e40e1a2c95560b9f936d8e29de8cd858480f"},
}
1 change: 1 addition & 0 deletions proto
Submodule proto added at 6854ff

0 comments on commit ec4c61f

Please sign in to comment.