Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Mamadou Saliou DIALLO
Not Alone
Commits
b5d55e28
Commit
b5d55e28
authored
Dec 09, 2020
by
Mamadou Saliou DIALLO
Browse files
get new modification from upstream
parent
9dbc3179
Changes
17
Expand all
Hide whitespace changes
Inline
Side-by-side
not-alone-core/src/main/thrift/game-service.thrift
View file @
b5d55e28
...
...
@@ -16,7 +16,7 @@ struct PlayerID{
1: string id
}
service GameServ
erServ
ice {
service GameService {
i32 createGame(i32 numberOfPlayers)
...
...
not-alone-core/src/main/thrift/player-service.thrift
View file @
b5d55e28
...
...
@@ -44,7 +44,7 @@ struct BoardGameState {
service PlayerService {
bool ping() throws (1:common.InvalidOperationException e)
string startGame(
BoardGameState boardGameState
)
string startGame(
i32 gameId
)
PlayerStateResponse blockActions()
PlayerStateResponse unblockActions()
void showPlayedCard()
...
...
not-alone-doc/pom.xml
View file @
b5d55e28
...
...
@@ -51,6 +51,7 @@
<sourceHighlighter>coderay</sourceHighlighter>
-->
<attributes>
<sourceHighlighter>
coderay
</sourceHighlighter>
<icons>
font
</icons>
<pagenums/>
<toc/>
...
...
not-alone-doc/src/doc/asciidoc/_sections/conception.adoc
View file @
b5d55e28
=
Conception
d
é
taill
é
e
//:
source
-
highlighter
:
rouge
==
Game
Server
[
source
,
java
]
----
class
Klass
{
String
field
;
}
----
[
source
,
ocl
]
----
context
Klass
inv
:
field
->
select
()
----
.
GameSever
[
plantuml
]
....
...
...
@@ -78,4 +94,4 @@ partition Game::run() {
:
Game
Start
>
stop
}
----
----
\ No newline at end of file
not-alone-player/package.json
View file @
b5d55e28
{
"name"
:
"not-alone-
web
"
,
"name"
:
"not-alone-
player
"
,
"version"
:
"0.0.0"
,
"main"
:
"dist/main.js"
,
"scripts"
:
{
"prebuild"
:
"tslint -c tslint.json -p tsconfig.json --fix"
,
"build"
:
"tsc"
,
"prestart"
:
"npm run build"
,
"start"
:
"node ."
,
"start"
:
"node .
/dist/main.js
"
,
"test"
:
"echo
\"
Error: no test specified
\"
&& exit 1"
,
"codegen"
:
"
\"
./node_modules/.bin/thrift-typescript
\"
--target thrift-server --sourceDir
\"
../not-alone-core/src/main/thrift/
\"
--outDir
\"
./src/codegen/
\"
"
},
...
...
not-alone-player/src/core/game.ts
0 → 100644
View file @
b5d55e28
export
interface
GameInterface
{
createGame
(
numberOfPlayers
:
number
):
Promise
<
number
>
;
join
(
gameId
:
number
):
Promise
<
number
>
;
}
not-alone-player/src/main.ts
0 → 100644
View file @
b5d55e28
import
{
ThriftServer
}
from
'
./thrift/thrift-server
'
;
/**
* Port used for local Thrift server.
*/
const
LOCAL_PORT
=
8090
;
class
Main
{
private
server
:
ThriftServer
;
constructor
()
{
console
.
log
(
'
Main class
'
);
this
.
server
=
new
ThriftServer
(
LOCAL_PORT
);
}
}
const
main
:
Main
=
new
Main
();
not-alone-player/src/thrift/game-proxy.ts
0 → 100644
View file @
b5d55e28
import
{
Client
}
from
'
src/codegen/common/GameService
'
;
import
{
GameInterface
}
from
'
../core/game
'
;
import
{
CoreOptions
}
from
'
request
'
;
import
{
createHttpClient
,
ICreateHttpClientOptions
}
from
'
@creditkarma/thrift-client
'
;
import
{
IJoinRequest
,
JoinRequest
}
from
'
../codegen/common/JoinRequest
'
;
export
class
GameProxy
implements
GameInterface
{
private
thriftClient
:
Client
<
CoreOptions
>
;
constructor
(
options
:
ICreateHttpClientOptions
)
{
this
.
thriftClient
=
createHttpClient
(
Client
,
options
);
}
createGame
(
numberOfPlayers
:
number
):
Promise
<
number
>
{
return
this
.
thriftClient
.
createGame
(
numberOfPlayers
);
}
join
(
gameId
:
number
):
Promise
<
number
>
{
const
request
:
IJoinRequest
=
new
JoinRequest
();
request
.
name
=
'
me
'
;
return
this
.
thriftClient
.
join
(
gameId
,
request
);
}
}
not-alone-player/src/thrift/thrift-server.ts
View file @
b5d55e28
...
...
@@ -5,12 +5,11 @@ import * as express from 'express';
import
{
createThriftServer
}
from
'
@creditkarma/thrift-server-express
'
;
const
handler
:
ClientServiceHandler
<
express
.
Request
>
=
new
ClientServiceHandler
<
express
.
Request
>
();
const
PORT
=
8090
;
export
class
ThriftServer
{
private
app
:
express
.
Application
;
constructor
()
{
constructor
(
port
:
number
)
{
this
.
app
=
createThriftServer
({
path
:
'
/thrift
'
,
thriftOptions
:
{
...
...
@@ -18,8 +17,8 @@ export class ThriftServer {
handler
:
new
GameService
.
Processor
(
handler
),
},
});
this
.
app
.
listen
(
PORT
,
()
=>
{
console
.
log
(
`Express server listening on port:
${
PORT
}
`
);
this
.
app
.
listen
(
port
,
()
=>
{
console
.
log
(
`
Thrift
Express server listening on port:
${
port
}
`
);
});
}
}
...
...
not-alone-player/tsconfig.json
View file @
b5d55e28
...
...
@@ -2,14 +2,15 @@
"compileOnSave"
:
false
,
"compilerOptions"
:
{
"baseUrl"
:
"./"
,
"outDir"
:
"./dist/
out-tsc
"
,
"outDir"
:
"./dist/"
,
"sourceMap"
:
true
,
"declaration"
:
false
,
"module"
:
"
ES6
"
,
"module"
:
"
CommonJS
"
,
"moduleResolution"
:
"node"
,
"emitDecoratorMetadata"
:
true
,
"experimentalDecorators"
:
true
,
"target"
:
"ES5"
,
"strict"
:
true
,
"target"
:
"ES2017"
,
"typeRoots"
:
[
"node_modules/@types"
],
...
...
not-alone-server/pom.xml
View file @
b5d55e28
...
...
@@ -61,6 +61,11 @@
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
</plugin>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-site-plugin
</artifactId>
<version>
3.9.1
</version>
</plugin>
</plugins>
</build>
...
...
not-alone-server/src/main/java/fr/univnantes/alma/NotAloneApplication.java
View file @
b5d55e28
package
fr.univnantes.alma
;
import
fr.univnantes.alma.thrift.GameServ
erServ
ice
;
import
fr.univnantes.alma.thrift.GameService
;
import
fr.univnantes.alma.handler.GameServiceHandler
;
import
org.apache.thrift.protocol.TBinaryProtocol
;
import
org.apache.thrift.protocol.TProtocolFactory
;
...
...
@@ -30,7 +30,7 @@ public class NotAloneApplication {
@Bean
public
ServletRegistrationBean
gameServer
(
TProtocolFactory
protocolFactory
,
GameServiceHandler
handler
)
{
TServlet
tServlet
=
new
TServlet
(
new
GameServ
erServ
ice
.
Processor
<
GameServiceHandler
>(
handler
),
protocolFactory
);
TServlet
tServlet
=
new
TServlet
(
new
GameService
.
Processor
<
GameServiceHandler
>(
handler
),
protocolFactory
);
return
new
ServletRegistrationBean
(
tServlet
,
"/api"
);
}
...
...
not-alone-server/src/main/java/fr/univnantes/alma/handler/GameServiceHandler.java
View file @
b5d55e28
...
...
@@ -3,12 +3,13 @@ package fr.univnantes.alma.handler;
import
fr.univnantes.alma.common.GameInterface
;
import
fr.univnantes.alma.common.GameJoinRequest
;
import
fr.univnantes.alma.thrift.*
;
import
fr.univnantes.alma.thrift.GameService
;
import
org.apache.thrift.TException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
@Component
public
class
GameServiceHandler
implements
GameServ
erServ
ice
.
Iface
{
public
class
GameServiceHandler
implements
GameService
.
Iface
{
@Autowired
GameInterface
service
;
...
...
not-alone-server/src/main/java/fr/univnantes/alma/player/PlayerInterface.java
0 → 100644
View file @
b5d55e28
package
fr.univnantes.alma.player
;
public
interface
PlayerInterface
{
void
startGame
(
int
gameId
);
}
not-alone-server/src/main/java/fr/univnantes/alma/player/PlayerProxy.java
0 → 100644
View file @
b5d55e28
package
fr.univnantes.alma.player
;
import
fr.univnantes.alma.thrift.PlayerService.Client
;
import
org.apache.thrift.TException
;
import
org.apache.thrift.protocol.TBinaryProtocol
;
import
org.apache.thrift.protocol.TProtocol
;
import
org.apache.thrift.transport.TSocket
;
import
org.apache.thrift.transport.TTransport
;
import
org.apache.thrift.transport.TTransportException
;
import
java.net.SocketAddress
;
public
class
PlayerProxy
implements
PlayerInterface
{
private
Client
client
;
public
PlayerProxy
(
String
addr
,
int
port
)
throws
TTransportException
{
TTransport
transport
=
new
TSocket
(
addr
,
port
);
TProtocol
protocol
=
new
TBinaryProtocol
(
transport
);
client
=
new
Client
(
protocol
);
}
@Override
public
void
startGame
(
int
gameId
)
{
try
{
client
.
startGame
(
gameId
);
}
catch
(
TException
e
)
{
e
.
printStackTrace
();
}
}
}
not-alone-server/src/test/java/fr/univnantes/alma/NotAloneApplicationTest.java
View file @
b5d55e28
package
fr.univnantes.alma
;
import
fr.univnantes.alma.thrift.GameServ
erServ
ice
;
import
fr.univnantes.alma.thrift.GameService
;
import
fr.univnantes.alma.thrift.JoinRequest
;
import
org.apache.thrift.TException
;
import
org.apache.thrift.protocol.TProtocol
;
...
...
@@ -24,7 +24,7 @@ class NotAloneApplicationTest {
@LocalServerPort
protected
int
port
;
protected
GameServ
erServ
ice
.
Iface
client
;
protected
GameService
.
Iface
client
;
@BeforeEach
public
void
setUp
()
throws
Exception
{
...
...
@@ -32,7 +32,7 @@ class NotAloneApplicationTest {
TProtocol
protocol
=
protocolFactory
.
getProtocol
(
transport
);
client
=
new
GameServ
erServ
ice
.
Client
(
protocol
);
client
=
new
GameService
.
Client
(
protocol
);
}
@Test
...
...
not-alone-web/package-lock.json
View file @
b5d55e28
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment