gameoverseer 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +4 -4
- data/Gemfile +3 -3
- data/Gemfile.lock +30 -30
- data/README.md +51 -51
- data/gameoverseer.gemspec +23 -23
- data/lib/gameoverseer/channels/channel_manager.rb +49 -49
- data/lib/gameoverseer/clients/client_manager.rb +66 -66
- data/lib/gameoverseer/console/console.rb +206 -206
- data/lib/gameoverseer/encryption_handler/encryption_handler.rb +40 -40
- data/lib/gameoverseer/input_handler/input_handler.rb +36 -36
- data/lib/gameoverseer/messages/message_manager.rb +42 -42
- data/lib/gameoverseer/packet_handler/packet_handler.rb +35 -35
- data/lib/gameoverseer/server/renet_server.rb +126 -126
- data/lib/gameoverseer/services/service.rb +111 -111
- data/lib/gameoverseer/services/services.rb +38 -38
- data/lib/gameoverseer/version.rb +4 -4
- data/lib/gameoverseer.rb +59 -59
- data/license.md +9 -9
- data/test/test_helper.rb +1 -1
- data/test-clients/test-client-gamma.rb +62 -62
- metadata +17 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8627b1078db7ca0404cacd500d5283d12ed65145
|
4
|
+
data.tar.gz: da7e1293a2fdb005c4cee2e4b34ac902123e0eff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53e017c17c26b4b0d4a71d5278ce067592cbb0590d28b0f0da85a7f5575cdd4638e4b2f134b8907004857fb44560796c51c66adfa3864ec91a8fabf31f8d8a39
|
7
|
+
data.tar.gz: d1a5aef06d8f2a11bfb0ddb2c52e367f4950b7a92f542bafb11402b07c6897e666723add171cc8068adf177c0dbc112b01e14d2ae5c650d889f59ba4e5d36ab8
|
data/.gitignore
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
log-*.txt
|
2
|
-
.yardoc/*
|
3
|
-
protocol.md
|
4
|
-
*.gem
|
1
|
+
log-*.txt
|
2
|
+
.yardoc/*
|
3
|
+
protocol.md
|
4
|
+
*.gem
|
data/Gemfile
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
source "https://rubygems.org"
|
2
|
-
|
3
|
-
gemspec
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
gemspec
|
data/Gemfile.lock
CHANGED
@@ -1,30 +1,30 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
gameoverseer (0.1.2)
|
5
|
-
concurrent-ruby
|
6
|
-
gosu (= 0.10.6)
|
7
|
-
multi_json
|
8
|
-
renet
|
9
|
-
|
10
|
-
GEM
|
11
|
-
remote: https://rubygems.org/
|
12
|
-
specs:
|
13
|
-
concurrent-ruby (1.0.1)
|
14
|
-
concurrent-ruby (1.0.1-java)
|
15
|
-
gosu (0.10.6)
|
16
|
-
gosu (0.10.6-x64-mingw32)
|
17
|
-
gosu (0.10.6-x86-mingw32)
|
18
|
-
multi_json (1.11.3)
|
19
|
-
renet (0.2.1)
|
20
|
-
|
21
|
-
PLATFORMS
|
22
|
-
java
|
23
|
-
x64-mingw32
|
24
|
-
x86-mingw32
|
25
|
-
|
26
|
-
DEPENDENCIES
|
27
|
-
gameoverseer!
|
28
|
-
|
29
|
-
BUNDLED WITH
|
30
|
-
1.11.2
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
gameoverseer (0.1.2)
|
5
|
+
concurrent-ruby
|
6
|
+
gosu (= 0.10.6)
|
7
|
+
multi_json
|
8
|
+
renet
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: https://rubygems.org/
|
12
|
+
specs:
|
13
|
+
concurrent-ruby (1.0.1)
|
14
|
+
concurrent-ruby (1.0.1-java)
|
15
|
+
gosu (0.10.6)
|
16
|
+
gosu (0.10.6-x64-mingw32)
|
17
|
+
gosu (0.10.6-x86-mingw32)
|
18
|
+
multi_json (1.11.3)
|
19
|
+
renet (0.2.1)
|
20
|
+
|
21
|
+
PLATFORMS
|
22
|
+
java
|
23
|
+
x64-mingw32
|
24
|
+
x86-mingw32
|
25
|
+
|
26
|
+
DEPENDENCIES
|
27
|
+
gameoverseer!
|
28
|
+
|
29
|
+
BUNDLED WITH
|
30
|
+
1.11.2
|
data/README.md
CHANGED
@@ -1,51 +1,51 @@
|
|
1
|
-
[![Code Climate](https://codeclimate.com/github/cyberarm/rewrite-gameoverseer/badges/gpa.svg)](https://codeclimate.com/github/cyberarm/rewrite-gameoverseer)
|
2
|
-
[![Inline docs](http://inch-ci.org/github/cyberarm/rewrite-gameoverseer.svg?branch=master)](http://inch-ci.org/github/cyberarm/rewrite-gameoverseer)
|
3
|
-
|
4
|
-
# GameOverseer
|
5
|
-
A game server, designed to be able to play host to up to 4 players in Planet Wars.
|
6
|
-
|
7
|
-
This repo is a complete rewrite of [GameOverseer](https://github.com/cyberarm/gameoverseer).
|
8
|
-
|
9
|
-
# Status
|
10
|
-
In development.
|
11
|
-
Any examples given are subject to be outdated at anytime.
|
12
|
-
|
13
|
-
# Install
|
14
|
-
### Using bundler
|
15
|
-
Add this to your Gemfile
|
16
|
-
``` ruby
|
17
|
-
gem "gameoverseer"
|
18
|
-
```
|
19
|
-
and run to install.
|
20
|
-
```
|
21
|
-
bundle install
|
22
|
-
```
|
23
|
-
|
24
|
-
### Or using RubyGems
|
25
|
-
```
|
26
|
-
gem install gameoverseer
|
27
|
-
```
|
28
|
-
|
29
|
-
# Usage
|
30
|
-
``` ruby
|
31
|
-
require 'gameoverseer'
|
32
|
-
|
33
|
-
# Write a service for your game
|
34
|
-
class GameWorld < GameOverseer::Service
|
35
|
-
def setup
|
36
|
-
channel_manager.register_channel('game_world', self)
|
37
|
-
end
|
38
|
-
|
39
|
-
def process(data)
|
40
|
-
# Do stuff with the data hash.
|
41
|
-
end
|
42
|
-
|
43
|
-
def version
|
44
|
-
"1.3.75"
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
host = "localhost"
|
49
|
-
port = 56789
|
50
|
-
GameOverseer.activate(host, port)
|
51
|
-
```
|
1
|
+
[![Code Climate](https://codeclimate.com/github/cyberarm/rewrite-gameoverseer/badges/gpa.svg)](https://codeclimate.com/github/cyberarm/rewrite-gameoverseer)
|
2
|
+
[![Inline docs](http://inch-ci.org/github/cyberarm/rewrite-gameoverseer.svg?branch=master)](http://inch-ci.org/github/cyberarm/rewrite-gameoverseer)
|
3
|
+
|
4
|
+
# GameOverseer
|
5
|
+
A game server, designed to be able to play host to up to 4 players in Planet Wars.
|
6
|
+
|
7
|
+
This repo is a complete rewrite of [GameOverseer](https://github.com/cyberarm/gameoverseer).
|
8
|
+
|
9
|
+
# Status
|
10
|
+
In development.
|
11
|
+
Any examples given are subject to be outdated at anytime.
|
12
|
+
|
13
|
+
# Install
|
14
|
+
### Using bundler
|
15
|
+
Add this to your Gemfile
|
16
|
+
``` ruby
|
17
|
+
gem "gameoverseer"
|
18
|
+
```
|
19
|
+
and run to install.
|
20
|
+
```
|
21
|
+
bundle install
|
22
|
+
```
|
23
|
+
|
24
|
+
### Or using RubyGems
|
25
|
+
```
|
26
|
+
gem install gameoverseer
|
27
|
+
```
|
28
|
+
|
29
|
+
# Usage
|
30
|
+
``` ruby
|
31
|
+
require 'gameoverseer'
|
32
|
+
|
33
|
+
# Write a service for your game
|
34
|
+
class GameWorld < GameOverseer::Service
|
35
|
+
def setup
|
36
|
+
channel_manager.register_channel('game_world', self)
|
37
|
+
end
|
38
|
+
|
39
|
+
def process(data)
|
40
|
+
# Do stuff with the data hash.
|
41
|
+
end
|
42
|
+
|
43
|
+
def version
|
44
|
+
"1.3.75"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
host = "localhost"
|
49
|
+
port = 56789
|
50
|
+
GameOverseer.activate(host, port)
|
51
|
+
```
|
data/gameoverseer.gemspec
CHANGED
@@ -1,23 +1,23 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
$:.push File.expand_path("../lib", __FILE__)
|
3
|
-
require "gameoverseer/version"
|
4
|
-
|
5
|
-
Gem::Specification.new do |s|
|
6
|
-
s.name = "gameoverseer"
|
7
|
-
s.version = GameOverseer::VERSION
|
8
|
-
s.authors = ["Cyberarm"]
|
9
|
-
s.email = ["matthewlikesrobots@gmail.com"]
|
10
|
-
s.homepage = "https://github.com/cyberarm/rewrite-gameoverseer"
|
11
|
-
s.summary = "Generic game server."
|
12
|
-
s.description = "GameOverseer is designed to simplify the making of multiplayer games by providing a way to simply and easily write a game server."
|
13
|
-
|
14
|
-
s.files = `git ls-files`.split("\n")
|
15
|
-
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
-
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
|
-
s.require_paths = ["lib", "bin"]
|
18
|
-
|
19
|
-
s.add_runtime_dependency "gosu", ">=0.10.6"
|
20
|
-
s.add_runtime_dependency "concurrent-ruby"
|
21
|
-
s.add_runtime_dependency "renet"
|
22
|
-
s.add_runtime_dependency "multi_json"
|
23
|
-
end
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "gameoverseer/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "gameoverseer"
|
7
|
+
s.version = GameOverseer::VERSION
|
8
|
+
s.authors = ["Cyberarm"]
|
9
|
+
s.email = ["matthewlikesrobots@gmail.com"]
|
10
|
+
s.homepage = "https://github.com/cyberarm/rewrite-gameoverseer"
|
11
|
+
s.summary = "Generic game server."
|
12
|
+
s.description = "GameOverseer is designed to simplify the making of multiplayer games by providing a way to simply and easily write a game server."
|
13
|
+
|
14
|
+
s.files = `git ls-files`.split("\n")
|
15
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
|
+
s.require_paths = ["lib", "bin"]
|
18
|
+
|
19
|
+
s.add_runtime_dependency "gosu", "~> 0.10", ">= 0.10.6"
|
20
|
+
s.add_runtime_dependency "concurrent-ruby"
|
21
|
+
s.add_runtime_dependency "renet", "~> 0.2", ">= 0.2.2"
|
22
|
+
s.add_runtime_dependency "multi_json"
|
23
|
+
end
|
@@ -1,49 +1,49 @@
|
|
1
|
-
module GameOverseer
|
2
|
-
|
3
|
-
# Handles routing packets to the services that subscribe to channels
|
4
|
-
class ChannelManager
|
5
|
-
CHAT = 0
|
6
|
-
WORLD= 1
|
7
|
-
HANDSHAKE = 2
|
8
|
-
FAULT=3
|
9
|
-
|
10
|
-
def initialize
|
11
|
-
@channels = {}
|
12
|
-
ChannelManager.instance = self
|
13
|
-
end
|
14
|
-
|
15
|
-
# Enables a service to subscribe to a channel
|
16
|
-
# @param channel [String]
|
17
|
-
# @param service [Service]
|
18
|
-
def register_channel(channel, service)
|
19
|
-
_channel = channel.downcase
|
20
|
-
unless @channels[_channel]
|
21
|
-
@channels[_channel] = service
|
22
|
-
GameOverseer::Console.log("ChannelManager> mapped '#{_channel}' to '#{service.class}'.")
|
23
|
-
else
|
24
|
-
raise "Could not map channel '#{_channel}' because '#{@channels[data[_channel]].class}' is already using it."
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
# Routes packet to {Service}
|
29
|
-
# @param client_id [Integer] ID of client that sent the packet
|
30
|
-
# @param data [Hash] data from packet
|
31
|
-
def send_to_service(client_id, data)
|
32
|
-
GameOverseer::Console.log("ChannelManager> sent '#{data}' to '#{@channels[data['channel']].class}'.")
|
33
|
-
@channels[data['channel']].client_id = client_id
|
34
|
-
@channels[data['channel']].process(data)
|
35
|
-
end
|
36
|
-
|
37
|
-
# Returns instance of active {ChannelManager}
|
38
|
-
# @return [ChannelManager]
|
39
|
-
def self.instance
|
40
|
-
@instance
|
41
|
-
end
|
42
|
-
|
43
|
-
# Sets instance of {ChannelManager} that is used through out the system
|
44
|
-
# @param _instance [ChannelManager]
|
45
|
-
def self.instance=_instance
|
46
|
-
@instance = _instance
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
1
|
+
module GameOverseer
|
2
|
+
|
3
|
+
# Handles routing packets to the services that subscribe to channels
|
4
|
+
class ChannelManager
|
5
|
+
CHAT = 0
|
6
|
+
WORLD= 1
|
7
|
+
HANDSHAKE = 2
|
8
|
+
FAULT=3
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
@channels = {}
|
12
|
+
ChannelManager.instance = self
|
13
|
+
end
|
14
|
+
|
15
|
+
# Enables a service to subscribe to a channel
|
16
|
+
# @param channel [String]
|
17
|
+
# @param service [Service]
|
18
|
+
def register_channel(channel, service)
|
19
|
+
_channel = channel.downcase
|
20
|
+
unless @channels[_channel]
|
21
|
+
@channels[_channel] = service
|
22
|
+
GameOverseer::Console.log("ChannelManager> mapped '#{_channel}' to '#{service.class}'.")
|
23
|
+
else
|
24
|
+
raise "Could not map channel '#{_channel}' because '#{@channels[data[_channel]].class}' is already using it."
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# Routes packet to {Service}
|
29
|
+
# @param client_id [Integer] ID of client that sent the packet
|
30
|
+
# @param data [Hash] data from packet
|
31
|
+
def send_to_service(client_id, data)
|
32
|
+
GameOverseer::Console.log("ChannelManager> sent '#{data}' to '#{@channels[data['channel']].class}'.")
|
33
|
+
@channels[data['channel']].client_id = client_id
|
34
|
+
@channels[data['channel']].process(data)
|
35
|
+
end
|
36
|
+
|
37
|
+
# Returns instance of active {ChannelManager}
|
38
|
+
# @return [ChannelManager]
|
39
|
+
def self.instance
|
40
|
+
@instance
|
41
|
+
end
|
42
|
+
|
43
|
+
# Sets instance of {ChannelManager} that is used through out the system
|
44
|
+
# @param _instance [ChannelManager]
|
45
|
+
def self.instance=_instance
|
46
|
+
@instance = _instance
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -1,66 +1,66 @@
|
|
1
|
-
module GameOverseer
|
2
|
-
|
3
|
-
# Stores client data
|
4
|
-
class ClientManager
|
5
|
-
attr_accessor :clients
|
6
|
-
|
7
|
-
def initialize
|
8
|
-
ClientManager.instance = self
|
9
|
-
@clients = []
|
10
|
-
end
|
11
|
-
|
12
|
-
# Add client to clients list
|
13
|
-
# @param client_id [Integer]
|
14
|
-
# @param ip_address [String]
|
15
|
-
def add(client_id, ip_address)
|
16
|
-
@clients << {client_id: client_id, ip_address: ip_address}
|
17
|
-
GameOverseer::Services.client_connected(client_id, ip_address)
|
18
|
-
end
|
19
|
-
|
20
|
-
# Store client specific data in a {Hash}
|
21
|
-
# @param client_id [Integer] ID of client
|
22
|
-
# @param key [String|Symbol]
|
23
|
-
# @param value What the key should equal
|
24
|
-
def update(client_id, key, value)
|
25
|
-
@clients.each do |hash|
|
26
|
-
if hash[:client_id] == client_id
|
27
|
-
hash[key] = value
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
# Gets client data
|
33
|
-
# @param client_id [Integer]
|
34
|
-
# @return [Hash] hash containing client data
|
35
|
-
def get(client_id)
|
36
|
-
_hash = @clients.detect do |hash|
|
37
|
-
if hash[:client_id] == client_id
|
38
|
-
true
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
return _hash
|
43
|
-
end
|
44
|
-
|
45
|
-
# Removes client data and disconnects client
|
46
|
-
# @param client_id [Integer] ID of client
|
47
|
-
def remove(client_id)
|
48
|
-
@clients.each do |hash|
|
49
|
-
if hash[:client_id] == client_id
|
50
|
-
@clients.delete(hash)
|
51
|
-
GameOverseer::Services.client_disconnected(client_id)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
# @return [ClientManager]
|
57
|
-
def self.instance
|
58
|
-
@instance
|
59
|
-
end
|
60
|
-
|
61
|
-
# @param _instance [ClientManager]
|
62
|
-
def self.instance=_instance
|
63
|
-
@instance = _instance
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
1
|
+
module GameOverseer
|
2
|
+
|
3
|
+
# Stores client data
|
4
|
+
class ClientManager
|
5
|
+
attr_accessor :clients
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
ClientManager.instance = self
|
9
|
+
@clients = []
|
10
|
+
end
|
11
|
+
|
12
|
+
# Add client to clients list
|
13
|
+
# @param client_id [Integer]
|
14
|
+
# @param ip_address [String]
|
15
|
+
def add(client_id, ip_address)
|
16
|
+
@clients << {client_id: client_id, ip_address: ip_address}
|
17
|
+
GameOverseer::Services.client_connected(client_id, ip_address)
|
18
|
+
end
|
19
|
+
|
20
|
+
# Store client specific data in a {Hash}
|
21
|
+
# @param client_id [Integer] ID of client
|
22
|
+
# @param key [String|Symbol]
|
23
|
+
# @param value What the key should equal
|
24
|
+
def update(client_id, key, value)
|
25
|
+
@clients.each do |hash|
|
26
|
+
if hash[:client_id] == client_id
|
27
|
+
hash[key] = value
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# Gets client data
|
33
|
+
# @param client_id [Integer]
|
34
|
+
# @return [Hash] hash containing client data
|
35
|
+
def get(client_id)
|
36
|
+
_hash = @clients.detect do |hash|
|
37
|
+
if hash[:client_id] == client_id
|
38
|
+
true
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
return _hash
|
43
|
+
end
|
44
|
+
|
45
|
+
# Removes client data and disconnects client
|
46
|
+
# @param client_id [Integer] ID of client
|
47
|
+
def remove(client_id)
|
48
|
+
@clients.each do |hash|
|
49
|
+
if hash[:client_id] == client_id
|
50
|
+
@clients.delete(hash)
|
51
|
+
GameOverseer::Services.client_disconnected(client_id)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# @return [ClientManager]
|
57
|
+
def self.instance
|
58
|
+
@instance
|
59
|
+
end
|
60
|
+
|
61
|
+
# @param _instance [ClientManager]
|
62
|
+
def self.instance=_instance
|
63
|
+
@instance = _instance
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|