File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change 4
4
5
5
The Java client library for [ CodeGame] ( https://code-game.org ) .
6
6
7
+ ## Installation
8
+
9
+ Add this to your * pom.xml* :
10
+ ``` xml
11
+ <dependency >
12
+ <groupId >org.codegame</groupId >
13
+ <artifactId >client</artifactId >
14
+ <version >0.1.0</version >
15
+ </dependency >
16
+ ```
17
+
18
+ ## Usage
19
+
20
+ ``` java
21
+ // Create a new game socket.
22
+ var socket = new GameSocket (" games.code-game.org/example" );
23
+
24
+ // Create a new private game.
25
+ var game = socket. createGame(false , false , null );
26
+
27
+ // Join a game.
28
+ socket. join(game. id, " username" );
29
+
30
+ // Spectate a game.
31
+ socket. spectate(game. id);
32
+
33
+ // Connect with an existing session.
34
+ socket. restoreSession(" username" );
35
+
36
+ // Register an event listener for the `my_event` event.
37
+ socket. on(" my_event" , MyEvent . class, (data) - > {
38
+ // TODO: do something with `data`
39
+ });
40
+
41
+ // Send a `hello_world` command.
42
+ socket. send(" hello_world" , new HelloWorldCmd (" Hello, World!" ));
43
+
44
+ // Wait until the connection is closed.
45
+ socket. listen();
46
+ ```
47
+
7
48
## License
8
49
9
50
MIT License
You can’t perform that action at this time.
0 commit comments