gameoverseer-client 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: ad6101c2e2b10272e30528dc1a2e1e9bb3f79338
4
- data.tar.gz: 4f2530092e030a77732253b52037e12b19c27bb1
2
+ SHA256:
3
+ metadata.gz: 780be3c8b42fed1d660f5a491339a458aec7003819159aa963461876631b8c7b
4
+ data.tar.gz: 31c23cced9b9829deb6eab1083e5b15a7c92106176f87a4cc78ef1f4fd9df71b
5
5
  SHA512:
6
- metadata.gz: 94a0513d719bd42096ebe42c3c2df16ebe7f5b67901b1fd0b90edd922a84c92b01cf08e2560231810e38dbfd14a004e4792b58af0aeb4f5c34a67e85b4945588
7
- data.tar.gz: 5d5b7ddf98357a84674195dd2cbd32866305540bb109ccf2fe6bd9b99e5910be98df14da2ad23666d999988e9501fc612971e49b92821be3c341cd477b544dba
6
+ metadata.gz: a57f73d641b355291ad5259709da0c05fed6b334b5f8adf12a04c3a04fdfc27e5e6e76f07ccc6cdd1a8b0443c32031596cbe49aecea3b719c96dc68d8b5709e7
7
+ data.tar.gz: c51eee05a00940b42c9e310b1e94491d92567f1f4a64fa9a59d5458db5a1172d852c62b35729ee3ed211d9876f3fe44c28c228ddef9a5ce1a2047997916336e8
data/README.md CHANGED
@@ -1,41 +1,41 @@
1
- [![Code Climate](https://codeclimate.com/github/cyberarm/gameoverseer-client/badges/gpa.svg)](https://codeclimate.com/github/cyberarm/gameoverseer-client)
2
- [![Inline docs](http://inch-ci.org/github/cyberarm/gameoverseer-client.svg?branch=master)](http://inch-ci.org/github/cyberarm/gameoverseer-client)
3
-
4
- # GameOverseer::Client
5
-
6
- Client library for GameOverseer.
7
-
8
- ## Installation
9
-
10
- Add this line to your application's Gemfile:
11
-
12
- ```ruby
13
- gem 'gameoverseer-client'
14
- ```
15
-
16
- And then execute:
17
-
18
- $ bundle
19
-
20
- Or install it yourself as:
21
-
22
- $ gem install gameoverseer-client
23
-
24
- ## Usage
25
-
26
- Simple example
27
- ```ruby
28
- require "gameoverseer/client"
29
-
30
- client = GameOverseer::Client.new("localhost", 56789)
31
- client.transmit('world', 'connect', {access_token: "f2a..."})
32
- client.disconnect
33
- ```
34
-
35
- ## Contributing
36
-
37
- 1. Fork it ( https://github.com/cyberarm/gameoverseer-client/fork )
38
- 2. Create your feature branch (`git checkout -b my-new-feature`)
39
- 3. Commit your changes (`git commit -am 'Add some feature'`)
40
- 4. Push to the branch (`git push origin my-new-feature`)
41
- 5. Create a new Pull Request
1
+ [![Code Climate](https://codeclimate.com/github/cyberarm/gameoverseer-client/badges/gpa.svg)](https://codeclimate.com/github/cyberarm/gameoverseer-client)
2
+ [![Inline docs](http://inch-ci.org/github/cyberarm/gameoverseer-client.svg?branch=master)](http://inch-ci.org/github/cyberarm/gameoverseer-client)
3
+
4
+ # GameOverseer::Client
5
+
6
+ Client library for GameOverseer.
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem 'gameoverseer-client'
14
+ ```
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install gameoverseer-client
23
+
24
+ ## Usage
25
+
26
+ Simple example
27
+ ```ruby
28
+ require "gameoverseer/client"
29
+
30
+ client = GameOverseer::Client.new("localhost", 56789)
31
+ client.transmit('world', 'connect', {access_token: "f2a..."})
32
+ client.disconnect
33
+ ```
34
+
35
+ ## Contributing
36
+
37
+ 1. Fork it ( https://github.com/cyberarm/gameoverseer-client/fork )
38
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
39
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
40
+ 4. Push to the branch (`git push origin my-new-feature`)
41
+ 5. Create a new Pull Request
@@ -1,26 +1,26 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'gameoverseer/client/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "gameoverseer-client"
8
- spec.version = GameOverseer::Client::VERSION
9
- spec.authors = ["Cyberarm"]
10
- spec.email = ["matthewlikesrobots@gmail.com"]
11
- spec.summary = %q{Client library for GameOverseer.}
12
- spec.description = %q{Library for easily communicating with a GameOverseer server.}
13
- spec.homepage = "https://github.com/cyberarm/gameoverseer-client"
14
- spec.license = "MIT"
15
-
16
- spec.files = `git ls-files -z`.split("\x0")
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
20
-
21
- spec.add_dependency "renet", ">= 0.2.0"
22
- spec.add_dependency "multi_json"
23
-
24
- spec.add_development_dependency "bundler", "~> 1.7"
25
- spec.add_development_dependency "rake", "~> 10.0"
26
- end
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'gameoverseer/client/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "gameoverseer-client"
8
+ spec.version = GameOverseer::Client::VERSION
9
+ spec.authors = ["Cyberarm"]
10
+ spec.email = ["matthewlikesrobots@gmail.com"]
11
+ spec.summary = %q{Client library for GameOverseer.}
12
+ spec.description = %q{Library for easily communicating with a GameOverseer server.}
13
+ spec.homepage = "https://github.com/cyberarm/gameoverseer-client"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "renet", ">= 0.2.0"
22
+ spec.add_dependency "multi_json"
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.7"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ end
@@ -1,92 +1,95 @@
1
- require "renet"
2
- require "multi_json"
3
-
4
- require_relative "client/version"
5
- require_relative "client/service_manager"
6
- require_relative "client/service"
7
-
8
- module GameOverseer
9
- class Client
10
- CHAT = 0 # channel int. used for in-game chat
11
- WORLD= 1 # channel int. used for sending/receiving world state updates
12
- HANDSHAKE = 2 # channel int. used for authentication or similar purposes
13
- FAULT=3 # channel int. used to send/receive errors
14
- attr_reader :socket
15
-
16
- def initialize(host = "localhost", port = 56789, compression = true)
17
- @host = host
18
- @port = port
19
- @compression = compression
20
-
21
- GameOverseer::Client.instance = self
22
- @service_manager = ServiceManager.new
23
-
24
- @socket = ENet::Connection.new(host, port, 4, 0, 0)
25
- @socket.use_compression(compression)
26
- @socket.on_packet_receive(method(:handle_packet))
27
-
28
- connect
29
- end
30
-
31
- def self.instance
32
- @instance
33
- end
34
- def self.instance=instance
35
- @instance = instance
36
- end
37
-
38
- def connect(timeout = 1000) # default to 1 second
39
- tries = 0
40
- begin
41
- @socket.connect(timeout)
42
- rescue StandardError
43
- tries+=1
44
- retry unless tries > 3
45
- raise if tries > 3
46
- end
47
- end
48
-
49
- def online?
50
- @socket.online?
51
- end
52
-
53
- def connected?
54
- @socket.connected?
55
- end
56
-
57
- def handle_packet(data, channel)
58
- _data= data.chomp.strip
59
- data = MultiJson.load(_data)
60
- ServiceManager.instance.handle_packet(data, channel)
61
- end
62
-
63
- def disconnect(timeout = 1000)
64
- tries = 0
65
- begin
66
- @socket.disconnect(timeout)
67
- rescue StandardError
68
- tries+=1
69
- retry unless tries > 3
70
- raise if tries > 3
71
- end
72
- end
73
-
74
- def transmit(channel, mode, data = nil, channel_id = CHAT, reliable = false)
75
- raise "channel must be a String" unless channel.is_a?(String)
76
- raise "mode must be a String" unless mode.is_a?(String)
77
- raise "data must be a Hash" unless data.is_a?(Hash) or data == nil
78
- raise "reliable must be a Boolean" unless reliable.is_a?(TrueClass) or reliable.is_a?(FalseClass)
79
-
80
- if data
81
- message = MultiJson.dump({channel: channel, mode: mode, data: data})
82
- else
83
- message = MultiJson.dump({channel: channel, mode: mode})
84
- end
85
- @socket.send_packet(message, reliable, channel_id)
86
- end
87
-
88
- def update(timeout = 0)
89
- @socket.update(timeout)
90
- end
91
- end
92
- end
1
+ require "renet"
2
+ require "multi_json"
3
+ if defined?(Oj)
4
+ Oj.default_options = {mode: :strict}
5
+ end
6
+
7
+ require_relative "client/version"
8
+ require_relative "client/service_manager"
9
+ require_relative "client/service"
10
+
11
+ module GameOverseer
12
+ class Client
13
+ CHAT = 0 # channel int. used for in-game chat
14
+ WORLD= 1 # channel int. used for sending/receiving world state updates
15
+ HANDSHAKE = 2 # channel int. used for authentication or similar purposes
16
+ FAULT=3 # channel int. used to send/receive errors
17
+ attr_reader :socket
18
+
19
+ def initialize(host = "localhost", port = 56789, compression = true)
20
+ @host = host
21
+ @port = port
22
+ @compression = compression
23
+
24
+ GameOverseer::Client.instance = self
25
+ @service_manager = ServiceManager.new
26
+
27
+ @socket = ENet::Connection.new(host, port, 4, 0, 0)
28
+ @socket.use_compression(compression)
29
+ @socket.on_packet_receive(method(:handle_packet))
30
+
31
+ connect
32
+ end
33
+
34
+ def self.instance
35
+ @instance
36
+ end
37
+ def self.instance=instance
38
+ @instance = instance
39
+ end
40
+
41
+ def connect(timeout = 1000) # default to 1 second
42
+ tries = 0
43
+ begin
44
+ @socket.connect(timeout)
45
+ rescue StandardError
46
+ tries+=1
47
+ retry unless tries > 3
48
+ raise if tries > 3
49
+ end
50
+ end
51
+
52
+ def online?
53
+ @socket.online?
54
+ end
55
+
56
+ def connected?
57
+ @socket.connected?
58
+ end
59
+
60
+ def handle_packet(data, channel)
61
+ _data= data.chomp.strip
62
+ data = MultiJson.load(_data)
63
+ ServiceManager.instance.handle_packet(data, channel)
64
+ end
65
+
66
+ def disconnect(timeout = 1000)
67
+ tries = 0
68
+ begin
69
+ @socket.disconnect(timeout)
70
+ rescue StandardError
71
+ tries+=1
72
+ retry unless tries > 3
73
+ raise if tries > 3
74
+ end
75
+ end
76
+
77
+ def transmit(channel, mode, data = nil, channel_id = CHAT, reliable = false)
78
+ raise "channel must be a String" unless channel.is_a?(String)
79
+ raise "mode must be a String" unless mode.is_a?(String)
80
+ raise "data must be a Hash" unless data.is_a?(Hash) or data == nil
81
+ raise "reliable must be a Boolean" unless reliable.is_a?(TrueClass) or reliable.is_a?(FalseClass)
82
+
83
+ if data
84
+ message = MultiJson.dump({channel: channel, mode: mode, data: data})
85
+ else
86
+ message = MultiJson.dump({channel: channel, mode: mode})
87
+ end
88
+ @socket.send_packet(message, reliable, channel_id)
89
+ end
90
+
91
+ def update(timeout = 0)
92
+ @socket.update(timeout)
93
+ end
94
+ end
95
+ end
@@ -1,5 +1,5 @@
1
1
  module GameOverseer
2
2
  class Client
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gameoverseer-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cyberarm
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-14 00:00:00.000000000 Z
11
+ date: 2018-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: renet
@@ -103,9 +103,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
103
  version: '0'
104
104
  requirements: []
105
105
  rubyforge_project:
106
- rubygems_version: 2.6.8
106
+ rubygems_version: 2.7.6
107
107
  signing_key:
108
108
  specification_version: 4
109
109
  summary: Client library for GameOverseer.
110
110
  test_files: []
111
- has_rdoc: