mrpin-sdk 0.3.141 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +47 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +65 -0
- data/Rakefile +1 -0
- data/app/assets/stylesheets/mrpin/sign_in.css +32 -0
- data/app/assets/stylesheets/mrpin.css.scss +3 -0
- data/app/views/devise/sessions/new.html.erb +16 -0
- data/app/views/layouts/devise.html.erb +12 -0
- data/lib/mrpin/all_files.rb +48 -0
- data/lib/mrpin/api/base/api_object.rb +48 -0
- data/lib/mrpin/api/base/handler_base.rb +86 -0
- data/lib/mrpin/api/base/request_base.rb +15 -0
- data/lib/mrpin/api/base/response_base.rb +29 -0
- data/lib/mrpin/api/bundles/init/handler_bundles_init.rb +36 -0
- data/lib/mrpin/api/bundles/init/request_bundles_init.rb +7 -0
- data/lib/mrpin/api/bundles/init/response_bundles_init.rb +5 -0
- data/lib/mrpin/api/packs/requests_pack.rb +38 -0
- data/lib/mrpin/api/packs/responses_pack.rb +38 -0
- data/lib/mrpin/api/platform/base/handler_platform_base.rb +26 -0
- data/lib/mrpin/api/platform/base/request_platform_base.rb +54 -0
- data/lib/mrpin/api/platform/report/handler_report_error.rb +74 -0
- data/lib/mrpin/api/platform/report/request_report_error.rb +20 -0
- data/lib/mrpin/api/standard/response_error.rb +19 -0
- data/lib/mrpin/api/standard/response_ok.rb +18 -0
- data/lib/mrpin/api/standard/response_session_end.rb +21 -0
- data/lib/mrpin/api/standard/response_with_url_data.rb +7 -0
- data/lib/mrpin/api/system/echo/handler_system_echo.rb +25 -0
- data/lib/mrpin/api/system/echo/request_system_echo.rb +19 -0
- data/lib/mrpin/config/initializers/00_carrier_wave.rb +4 -0
- data/lib/mrpin/config/initializers/01_devise.rb +264 -0
- data/lib/mrpin/config/initializers/02_mongo.rb +2 -0
- data/lib/mrpin/config/initializers/03_i18n.rb +3 -0
- data/lib/mrpin/config/initializers.rb +7 -0
- data/lib/mrpin/config/locales/rails_admin.en.yml +10 -0
- data/lib/mrpin/controllers/application_controller_base.rb +14 -0
- data/lib/mrpin/controllers/system_controller_base.rb +222 -0
- data/lib/mrpin/core/admin/admin_user.rb +39 -0
- data/lib/mrpin/core/admin/e_admin_user_role.rb +4 -0
- data/lib/mrpin/core/app_config_base.rb +48 -0
- data/lib/mrpin/core/app_info/app_info_base.rb +413 -0
- data/lib/mrpin/core/app_info/e_app_state.rb +13 -0
- data/lib/mrpin/core/base/amf_serializable.rb +16 -0
- data/lib/mrpin/core/base/enum_base.rb +12 -0
- data/lib/mrpin/core/base/info_base.rb +18 -0
- data/lib/mrpin/core/base/manager_base.rb +74 -0
- data/lib/mrpin/core/base/manager_with_json_data.rb +98 -0
- data/lib/mrpin/core/base/model_base.rb +219 -0
- data/lib/mrpin/core/bundles/bundle_base.rb +197 -0
- data/lib/mrpin/core/bundles/bundle_info_base.rb +29 -0
- data/lib/mrpin/core/bundles/e_build_type.rb +7 -0
- data/lib/mrpin/core/bundles/manager_bundles_base.rb +56 -0
- data/lib/mrpin/core/constants/constants_remote.rb +14 -0
- data/lib/mrpin/core/currency_exchanger/base/exchanger_base.rb +21 -0
- data/lib/mrpin/core/currency_exchanger/currency_exchanger.rb +40 -0
- data/lib/mrpin/core/currency_exchanger/e_currency_type.rb +8 -0
- data/lib/mrpin/core/currency_exchanger/fixer/exchanger_fixer.rb +40 -0
- data/lib/mrpin/core/currency_exchanger/local/exchanger_local.rb +23 -0
- data/lib/mrpin/core/currency_exchanger/yahoo/exchanger_yahoo.rb +34 -0
- data/lib/mrpin/core/exceptions/assertion_error.rb +3 -0
- data/lib/mrpin/core/extensions/hash.rb +25 -0
- data/lib/mrpin/core/extensions/mongoid_id_alias.rb +7 -0
- data/lib/mrpin/core/extensions/object.rb +57 -0
- data/lib/mrpin/core/extensions/thread.rb +23 -0
- data/lib/mrpin/core/extensions/time.rb +5 -0
- data/lib/mrpin/core/logger/logger_sdk.rb +14 -0
- data/lib/mrpin/core/platform/e_platform_type.rb +14 -0
- data/lib/mrpin/core/player/e_player_role.rb +7 -0
- data/lib/mrpin/core/player/e_sex_type.rb +7 -0
- data/lib/mrpin/core/player/player_statistic_base.rb +50 -0
- data/lib/mrpin/core/purchase/e_sale_type.rb +7 -0
- data/lib/mrpin/core/remote/e_response_type.rb +4 -0
- data/lib/mrpin/core/remote/http/manager_remote_http.rb +107 -0
- data/lib/mrpin/core/remote/socket/base/extensions/manager_remote_socket_api.rb +43 -0
- data/lib/mrpin/core/remote/socket/base/extensions/manager_remote_socket_disconnect.rb +69 -0
- data/lib/mrpin/core/remote/socket/base/extensions/manager_remote_socket_handle.rb +155 -0
- data/lib/mrpin/core/remote/socket/base/extensions/manager_remote_socket_sessions.rb +41 -0
- data/lib/mrpin/core/remote/socket/base/extensions/manager_remote_socket_statistic.rb +41 -0
- data/lib/mrpin/core/remote/socket/base/extensions/network_interface_helper.rb +53 -0
- data/lib/mrpin/core/remote/socket/base/manager_remote_socket_base.rb +131 -0
- data/lib/mrpin/core/remote/socket/base/socket_client_base.rb +181 -0
- data/lib/mrpin/core/remote/socket/base/socket_client_crossdomain.rb +33 -0
- data/lib/mrpin/core/remote/socket/flash/manager_remote_socket_flash.rb +51 -0
- data/lib/mrpin/core/remote/socket/flash/socket_client_flash.rb +21 -0
- data/lib/mrpin/core/remote/socket/unity/manager_remote_socket_unity.rb +58 -0
- data/lib/mrpin/core/remote/socket/unity/socket_client_unity.rb +19 -0
- data/lib/mrpin/core/remote/socket/websocket/manager_remote_web_sockets.rb +101 -0
- data/lib/mrpin/core/remote/socket/websocket/socket_client_web_sockets.rb +129 -0
- data/lib/mrpin/core/remote/socket/with_policy/socket_client_with_policy.rb +66 -0
- data/lib/mrpin/core/review.rb +231 -0
- data/lib/mrpin/core/scheduler/manager_scheduler.rb +66 -0
- data/lib/mrpin/core/statistic/error_client_base.rb +136 -0
- data/lib/mrpin/core/statistic/error_server_base.rb +93 -0
- data/lib/mrpin/core/statistic/manager_statistics_base.rb +221 -0
- data/lib/mrpin/core/statistic/statistic_application_base.rb +88 -0
- data/lib/mrpin/core/statistic/statistic_config_base.rb +38 -0
- data/lib/mrpin/core/statistic/system_handler_profiler.rb +85 -0
- data/lib/mrpin/core/string/e_language_type.rb +29 -0
- data/lib/mrpin/core/string/e_string_type_base.rb +14 -0
- data/lib/mrpin/core/string/localization_base.rb +77 -0
- data/lib/mrpin/core/string/localization_base_map.rb +303 -0
- data/lib/mrpin/core/string/manager_string_base.rb +159 -0
- data/lib/mrpin/core/threads/thread_with_task.rb +62 -0
- data/lib/mrpin/core/uploaders/aws/aws_file_info.rb +16 -0
- data/lib/mrpin/core/uploaders/aws/aws_uploader.rb +229 -0
- data/lib/mrpin/core/uploaders/carrierwave/file_uploader.rb +7 -0
- data/lib/mrpin/core/uploaders/carrierwave/file_uploader_helpers_base.rb +66 -0
- data/lib/mrpin/core/uploaders/carrierwave/file_uploader_helpers_local.rb +111 -0
- data/lib/mrpin/core/uploaders/carrierwave/file_uploader_helpers_s3.rb +87 -0
- data/lib/mrpin/core/uploaders/carrierwave/zip_uploader.rb +10 -0
- data/lib/mrpin/core/utils/mongo.rb +41 -0
- data/lib/mrpin/core/utils/sorter_base.rb +344 -0
- data/lib/mrpin/core/utils/utils_io.rb +27 -0
- data/lib/mrpin/core/utils/utils_string.rb +17 -0
- data/lib/mrpin/core/utils/utils_zip.rb +58 -0
- data/lib/mrpin/libs/rails_admin/localization.rb +70 -0
- data/lib/mrpin/libs.rb +11 -0
- data/lib/mrpin/rails/engine.rb +11 -0
- data/lib/mrpin/vendors.rb +19 -0
- data/lib/mrpin/version.rb +3 -0
- data/lib/mrpin-sdk.rb +6 -0
- data/mrpin-sdk.gemspec +54 -0
- metadata +163 -96
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6af07606ad52702d08d90fc46883b853de30fabb
|
4
|
+
data.tar.gz: 14a4baf2c541e6c3c1715d6613c84a8c4b34de21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b68a64e3bd6130bf3e20c67bbcf23695dee23d639f2435187d412b71eb9c6305bd822891ad4b41d63971e080e603dd60047c9a025d62e4b7775b10a66dd43e10
|
7
|
+
data.tar.gz: 52e2969511e350c5fdf2e4f993461a0bd15883f79af886ff10ac6f078cfd331c514dc79d5bf97f861a145fcb29bbfe959b922827a3aad973204ec7a0c4488274
|
data/.gitignore
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
|
19
|
+
capybara-*.html
|
20
|
+
.rspec
|
21
|
+
/log
|
22
|
+
/tmp
|
23
|
+
/db/*.sqlite3
|
24
|
+
/public/system
|
25
|
+
/coverage/
|
26
|
+
/spec/tmp
|
27
|
+
**.orig
|
28
|
+
rerun.txt
|
29
|
+
pickle-email-*.html
|
30
|
+
|
31
|
+
config/initializers/secret_token.rb
|
32
|
+
config/secrets.yml
|
33
|
+
|
34
|
+
## Environment normalisation:
|
35
|
+
/.bundle
|
36
|
+
/vendor/bundle
|
37
|
+
|
38
|
+
# these should all be checked in to normalise the environment:
|
39
|
+
# Gemfile.lock, .ruby-version, .ruby-gemset
|
40
|
+
|
41
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
42
|
+
.rvmrc
|
43
|
+
|
44
|
+
# if using bower-rails ignore default bower_components path bower.json files
|
45
|
+
/vendor/assets/bower_components
|
46
|
+
*.bowerrc
|
47
|
+
bower.json
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 gregorytkach
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# Mrpin::Sdk
|
2
|
+
|
3
|
+
|
4
|
+
TODO: Write a gem description
|
5
|
+
|
6
|
+
[DEVELOPMENT]
|
7
|
+
|
8
|
+
## Server game ports
|
9
|
+
|
10
|
+
5843 port for fetch crossdomain.xml
|
11
|
+
|
12
|
+
5001 port for connect flash clients
|
13
|
+
5002 port for connect js clients
|
14
|
+
5102 secure port for connect js clients
|
15
|
+
5003 port for connect unity clients
|
16
|
+
|
17
|
+
## Auth ports
|
18
|
+
6843 port for fetch crossdomain.xml
|
19
|
+
|
20
|
+
6010 port for games servers
|
21
|
+
|
22
|
+
6002 port for connect js clients
|
23
|
+
6102 secure port for connect js clients
|
24
|
+
6003 port for connect unity clients
|
25
|
+
|
26
|
+
[Production]
|
27
|
+
|
28
|
+
## Server game ports
|
29
|
+
|
30
|
+
843 port for fetch crossdomain.xml
|
31
|
+
|
32
|
+
5001 port for connect flash clients
|
33
|
+
5002 port for connect js clients
|
34
|
+
5102 secure port for connect js clients
|
35
|
+
5003 port for connect unity clients
|
36
|
+
|
37
|
+
## Auth ports
|
38
|
+
843 port for fetch crossdomain.xml
|
39
|
+
|
40
|
+
6010 port for games servers
|
41
|
+
|
42
|
+
6002 port for connect js clients
|
43
|
+
6102 secure port for connect js clients
|
44
|
+
6003 port for connect unity clients
|
45
|
+
|
46
|
+
|
47
|
+
And then execute:
|
48
|
+
|
49
|
+
$ bundle
|
50
|
+
|
51
|
+
Or install it yourself as:
|
52
|
+
|
53
|
+
$ gem install mrpin-sdk
|
54
|
+
|
55
|
+
## Usage
|
56
|
+
|
57
|
+
TODO: Write usage instructions here
|
58
|
+
|
59
|
+
## Contributing
|
60
|
+
|
61
|
+
1. Fork it
|
62
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
63
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
64
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
65
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
@@ -0,0 +1,32 @@
|
|
1
|
+
/*User sign in form. */
|
2
|
+
.border-form-div
|
3
|
+
{
|
4
|
+
max-width: 240px;
|
5
|
+
padding: 0 20px 10px;
|
6
|
+
margin: 5% auto 20px;
|
7
|
+
background-color: #fff;
|
8
|
+
border: 1px solid #e5e5e5;
|
9
|
+
-webkit-border-radius: 5px;
|
10
|
+
-moz-border-radius: 5px;
|
11
|
+
border-radius: 5px;
|
12
|
+
-webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
|
13
|
+
-moz-box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
|
14
|
+
box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
|
15
|
+
}
|
16
|
+
|
17
|
+
.border-form-div .form-signin-heading,
|
18
|
+
.border-form-div .checkbox
|
19
|
+
{
|
20
|
+
margin-bottom: 10px;
|
21
|
+
}
|
22
|
+
|
23
|
+
.border-form-div input[type="text"],
|
24
|
+
.border-form-div input[type="email"],
|
25
|
+
.border-form-div input[type="password"]
|
26
|
+
{
|
27
|
+
font-size: 13px;
|
28
|
+
height: auto;
|
29
|
+
margin-bottom: 10px;
|
30
|
+
padding: 5px 5px;
|
31
|
+
width: 200px;
|
32
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<div class="border-form-div">
|
2
|
+
|
3
|
+
<h2>Sign in</h2>
|
4
|
+
|
5
|
+
<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
|
6
|
+
<%= f.text_field :email, :autofocus => true, :placeholder => 'Email'%>
|
7
|
+
<%= f.password_field :password, :placeholder => 'Password'%>
|
8
|
+
<% if devise_mapping.rememberable? -%>
|
9
|
+
<div><%= f.check_box :remember_me %> <%= f.label :remember_me %></div>
|
10
|
+
<% end -%>
|
11
|
+
<%= f.submit 'Sign in', :class=>'btn btn-primary' %>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
<%= render 'devise/shared/links' %>
|
15
|
+
|
16
|
+
</div>
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require_at_first =
|
2
|
+
%w(
|
3
|
+
/api/base/
|
4
|
+
/api/standard/
|
5
|
+
|
6
|
+
/core/base/extensions/
|
7
|
+
/core/base/
|
8
|
+
/core/extensions/
|
9
|
+
/core/remote/socket/base/extensions/
|
10
|
+
/core/remote/socket/base/
|
11
|
+
/core/uploaders/
|
12
|
+
)
|
13
|
+
|
14
|
+
require_at_first.each do |path|
|
15
|
+
full_path = File.join(File.dirname(__FILE__), path, '**/*.rb')
|
16
|
+
|
17
|
+
Dir[full_path].each do |file|
|
18
|
+
require file
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
dirs = %w(api controllers core)
|
23
|
+
|
24
|
+
files_ignore = []
|
25
|
+
|
26
|
+
dirs_ignore =
|
27
|
+
%w(
|
28
|
+
)
|
29
|
+
|
30
|
+
dirs_ignore.each do |dir|
|
31
|
+
full_path = File.join(File.dirname(__FILE__), dir, '**/*.rb')
|
32
|
+
|
33
|
+
files_ignore += Dir[full_path]
|
34
|
+
end
|
35
|
+
|
36
|
+
dirs.each do |dir|
|
37
|
+
full_path = File.join(File.dirname(__FILE__), dir, '**/*.rb')
|
38
|
+
|
39
|
+
files = Dir[full_path]
|
40
|
+
|
41
|
+
files -= files_ignore
|
42
|
+
|
43
|
+
files.each do |file|
|
44
|
+
require file
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Api
|
2
|
+
class ApiObject
|
3
|
+
|
4
|
+
#
|
5
|
+
# static methods
|
6
|
+
#
|
7
|
+
|
8
|
+
protected
|
9
|
+
def self.logger
|
10
|
+
if @logger.nil?
|
11
|
+
@logger = AppInfo.instance.logger
|
12
|
+
end
|
13
|
+
|
14
|
+
@logger
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
#
|
19
|
+
# Properties
|
20
|
+
#
|
21
|
+
|
22
|
+
public
|
23
|
+
attr_accessor :request_id
|
24
|
+
|
25
|
+
#
|
26
|
+
# Methods
|
27
|
+
#
|
28
|
+
|
29
|
+
# default constructor
|
30
|
+
public
|
31
|
+
def initialize(request_id = nil)
|
32
|
+
@request_id = request_id || -1
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
if Rails.env.development?
|
37
|
+
public
|
38
|
+
def report_log(action)
|
39
|
+
ApiObject.logger.info "request_id:\t\t#{self.request_id}\t\t#{action} #{self.class}"
|
40
|
+
end
|
41
|
+
else
|
42
|
+
public
|
43
|
+
def report_log(action)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
module Api
|
2
|
+
class HandlerBase
|
3
|
+
|
4
|
+
#
|
5
|
+
# Properties
|
6
|
+
#
|
7
|
+
|
8
|
+
attr_reader :requests_count
|
9
|
+
attr_reader :handle_duration_total
|
10
|
+
attr_reader :handle_duration_max
|
11
|
+
attr_reader :handle_duration_min
|
12
|
+
|
13
|
+
#
|
14
|
+
# Methods
|
15
|
+
#
|
16
|
+
|
17
|
+
# default constructor
|
18
|
+
def initialize(options = nil)
|
19
|
+
@stats_locker = Mutex.new
|
20
|
+
|
21
|
+
reset_handler_stats
|
22
|
+
|
23
|
+
@logger = AppInfo.instance.logger
|
24
|
+
end
|
25
|
+
|
26
|
+
public
|
27
|
+
def before_handle
|
28
|
+
end
|
29
|
+
|
30
|
+
public
|
31
|
+
def handle_request(session, request)
|
32
|
+
end
|
33
|
+
|
34
|
+
public
|
35
|
+
def post_handle(handle_start_at)
|
36
|
+
return if handle_start_at.nil?
|
37
|
+
|
38
|
+
handle_duration = ((Time.now - handle_start_at).to_f * 1000).to_i
|
39
|
+
|
40
|
+
@stats_locker.synchronize do
|
41
|
+
@requests_count += 1
|
42
|
+
@handle_duration_total += handle_duration
|
43
|
+
|
44
|
+
@handle_duration_min = [@handle_duration_min, handle_duration].min
|
45
|
+
@handle_duration_max = [@handle_duration_max, handle_duration].max
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
public
|
50
|
+
def reset_handler_stats
|
51
|
+
@stats_locker.synchronize do
|
52
|
+
@requests_count = 0
|
53
|
+
@handle_duration_total = 0
|
54
|
+
|
55
|
+
@handle_duration_max = 0
|
56
|
+
@handle_duration_min = 2_147_483_647
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
protected
|
61
|
+
def player_is_nil?(session, request_id)
|
62
|
+
result = session.player.nil?
|
63
|
+
|
64
|
+
if result
|
65
|
+
session.send_response_error(request_id)
|
66
|
+
|
67
|
+
AppInfo.instance.on_server_error("player is nil in handler #{self.class}")
|
68
|
+
end
|
69
|
+
|
70
|
+
result
|
71
|
+
end
|
72
|
+
|
73
|
+
protected
|
74
|
+
def send_response_ok_unless_error(session, request_id, error = nil)
|
75
|
+
if error.nil?
|
76
|
+
response = Api::ResponseOk.new(request_id)
|
77
|
+
else
|
78
|
+
response = Api::ResponseError.new(request_id)
|
79
|
+
response.description = error
|
80
|
+
end
|
81
|
+
|
82
|
+
session.send_response(response)
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Api
|
2
|
+
class ResponseBase < ApiObject
|
3
|
+
|
4
|
+
#
|
5
|
+
# Properties
|
6
|
+
#
|
7
|
+
|
8
|
+
#
|
9
|
+
# Methods
|
10
|
+
#
|
11
|
+
|
12
|
+
# default constructor
|
13
|
+
def initialize(request_id = nil)
|
14
|
+
super
|
15
|
+
end
|
16
|
+
|
17
|
+
public
|
18
|
+
def report_log(action)
|
19
|
+
end
|
20
|
+
|
21
|
+
if Rails.env.development?
|
22
|
+
public
|
23
|
+
def report_log(action)
|
24
|
+
ApiObject.logger.info "response_id:\t\t#{self.request_id}\t\t#{action} #{self.class}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Api
|
2
|
+
class HandlerBundlesInit < HandlerBase
|
3
|
+
|
4
|
+
#
|
5
|
+
# Properties
|
6
|
+
#
|
7
|
+
|
8
|
+
#
|
9
|
+
# Methods
|
10
|
+
#
|
11
|
+
|
12
|
+
# default constructor
|
13
|
+
def initialize(options = nil)
|
14
|
+
super(options)
|
15
|
+
|
16
|
+
@managers_bundles_map = AppInfo.instance.managers_bundles_map
|
17
|
+
end
|
18
|
+
|
19
|
+
def handle_request(session, request)
|
20
|
+
super
|
21
|
+
|
22
|
+
response = ResponseBundlesInit.new(request.request_id)
|
23
|
+
|
24
|
+
manager_bundles = @managers_bundles_map[request.build_type]
|
25
|
+
|
26
|
+
if manager_bundles.nil?
|
27
|
+
response.url_data = nil
|
28
|
+
else
|
29
|
+
response.url_data = manager_bundles.url_client_data
|
30
|
+
end
|
31
|
+
|
32
|
+
session.send_response(response)
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Api
|
2
|
+
class RequestsPack < RequestBase
|
3
|
+
|
4
|
+
|
5
|
+
attr_accessor :requests
|
6
|
+
|
7
|
+
#
|
8
|
+
# methods
|
9
|
+
#
|
10
|
+
|
11
|
+
# default constructor
|
12
|
+
def initialize
|
13
|
+
super(-1)
|
14
|
+
|
15
|
+
@requests = []
|
16
|
+
end
|
17
|
+
|
18
|
+
public
|
19
|
+
def report_log(action)
|
20
|
+
end
|
21
|
+
|
22
|
+
if Rails.env.development?
|
23
|
+
public
|
24
|
+
def report_log(action)
|
25
|
+
logger = ApiObject.logger
|
26
|
+
|
27
|
+
logger.info '[REQUESTS PACK START]'
|
28
|
+
|
29
|
+
@requests.each do |response|
|
30
|
+
response.report_log(action)
|
31
|
+
end
|
32
|
+
|
33
|
+
logger.info '[REQUESTS PACK END]'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Api
|
2
|
+
class ResponsesPack < ResponseBase
|
3
|
+
|
4
|
+
|
5
|
+
attr_accessor :responses
|
6
|
+
|
7
|
+
#
|
8
|
+
# methods
|
9
|
+
#
|
10
|
+
|
11
|
+
# default constructor
|
12
|
+
def initialize
|
13
|
+
super(-1)
|
14
|
+
|
15
|
+
@responses = []
|
16
|
+
end
|
17
|
+
|
18
|
+
public
|
19
|
+
def report_log(action)
|
20
|
+
end
|
21
|
+
|
22
|
+
if Rails.env.development?
|
23
|
+
public
|
24
|
+
def report_log(action)
|
25
|
+
logger = ApiObject.logger
|
26
|
+
|
27
|
+
logger.info '[RESPONSES PACK START]'
|
28
|
+
|
29
|
+
@responses.each do |response|
|
30
|
+
response.report_log(action)
|
31
|
+
end
|
32
|
+
|
33
|
+
logger.info '[RESPONSES PACK END]'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Api
|
2
|
+
class HandlerPlatformBase < HandlerBase
|
3
|
+
|
4
|
+
#
|
5
|
+
# events
|
6
|
+
#
|
7
|
+
|
8
|
+
|
9
|
+
protected
|
10
|
+
def on_server_on_maintenance(session, request_id)
|
11
|
+
session.send_response_error(request_id, EStringTypeBase::EST_ERROR_SERVER_ON_MAINTENANCE)
|
12
|
+
end
|
13
|
+
|
14
|
+
#
|
15
|
+
# Methods
|
16
|
+
#
|
17
|
+
|
18
|
+
# default constructor
|
19
|
+
public
|
20
|
+
def initialize(options = nil)
|
21
|
+
super(options)
|
22
|
+
|
23
|
+
@manager_players = AppInfo.instance.manager_players
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module Api
|
2
|
+
class RequestPlatformBase < RequestBase
|
3
|
+
|
4
|
+
#
|
5
|
+
# Properties
|
6
|
+
#
|
7
|
+
|
8
|
+
public
|
9
|
+
def platform_info=(value)
|
10
|
+
@platform_info_compressed = value
|
11
|
+
end
|
12
|
+
|
13
|
+
public
|
14
|
+
def is_compressed=(value)
|
15
|
+
@is_compressed = value
|
16
|
+
end
|
17
|
+
|
18
|
+
public
|
19
|
+
def platform_info
|
20
|
+
if @platform_info.nil?
|
21
|
+
@platform_info = @is_compressed ? get_platform_info_uncompressed : @platform_info_compressed
|
22
|
+
|
23
|
+
@platform_info.recursive_symbolize_keys!
|
24
|
+
end
|
25
|
+
|
26
|
+
@platform_info
|
27
|
+
end
|
28
|
+
|
29
|
+
#
|
30
|
+
# Methods
|
31
|
+
#
|
32
|
+
|
33
|
+
# default constructor
|
34
|
+
public
|
35
|
+
def initialize(options = nil)
|
36
|
+
super(options)
|
37
|
+
|
38
|
+
@platform_info_compressed = nil
|
39
|
+
@platform_info = nil
|
40
|
+
@is_compressed = false
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
def get_platform_info_uncompressed
|
45
|
+
# we use base64 encoding instead string because as3 have troubles with reading binary to string from byte array
|
46
|
+
# we use base64 encoding instead byte array because js have troubles with sending byte array
|
47
|
+
platform_info_json = UtilsZip.decompress_base64(@platform_info_compressed)
|
48
|
+
|
49
|
+
result = JSON.parse(platform_info_json)
|
50
|
+
|
51
|
+
result
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|