socky 0.2.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +3 -25
- data/lib/socky.rb +1 -75
- metadata +20 -91
- data/CHANGELOG.textile +0 -88
- data/Rakefile +0 -30
- data/VERSION +0 -1
- data/bin/socky +0 -5
- data/lib/em-websocket_hacks.rb +0 -15
- data/lib/socky/connection.rb +0 -137
- data/lib/socky/connection/authentication.rb +0 -99
- data/lib/socky/connection/finders.rb +0 -67
- data/lib/socky/message.rb +0 -85
- data/lib/socky/misc.rb +0 -74
- data/lib/socky/net_request.rb +0 -27
- data/lib/socky/options.rb +0 -39
- data/lib/socky/options/config.rb +0 -79
- data/lib/socky/options/parser.rb +0 -93
- data/lib/socky/runner.rb +0 -95
- data/spec/em-websocket_spec.rb +0 -36
- data/spec/files/default.yml +0 -18
- data/spec/files/invalid.yml +0 -1
- data/spec/socky/connection/authentication_spec.rb +0 -183
- data/spec/socky/connection/finders_spec.rb +0 -188
- data/spec/socky/connection_spec.rb +0 -151
- data/spec/socky/message_spec.rb +0 -102
- data/spec/socky/misc_spec.rb +0 -74
- data/spec/socky/net_request_spec.rb +0 -42
- data/spec/socky/options/config_spec.rb +0 -72
- data/spec/socky/options/parser_spec.rb +0 -76
- data/spec/socky/options_spec.rb +0 -60
- data/spec/socky/runner_spec.rb +0 -88
- data/spec/socky_spec.rb +0 -89
- data/spec/spec_helper.rb +0 -6
- data/spec/support/stallion.rb +0 -96
data/README.textile
CHANGED
@@ -1,27 +1,5 @@
|
|
1
1
|
h1. Socky
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
* "Install":http://wiki.github.com/imanel/socky_gem/install the gem
|
8
|
-
* Read up about its "Usage":http://wiki.github.com/imanel/socky_gem/usage and "Configuration":http://wiki.github.com/imanel/socky_gem/configuration
|
9
|
-
* Try "Example Application":http://github.com/imanel/socky_example or "demo page":http://sockydemo.imanel.org
|
10
|
-
* Fork and Contribute your own modifications
|
11
|
-
|
12
|
-
h2. Runtime Dependencies
|
13
|
-
|
14
|
-
* EM-WebSocket: Backend for WebSocket server
|
15
|
-
* EM-HTTP-Client: Sending authorize requests
|
16
|
-
|
17
|
-
h2. License
|
18
|
-
|
19
|
-
(The MIT License)
|
20
|
-
|
21
|
-
Copyright (c) 2010 Bernard Potocki
|
22
|
-
|
23
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
24
|
-
|
25
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
26
|
-
|
27
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
3
|
+
"socky" ruby server gem changed name to "socky-server".
|
4
|
+
This is only transitional package. Please change install socky-server gem and remove this one.
|
5
|
+
You can find repository "here":http://github.com/socky/socky-server-ruby
|
data/lib/socky.rb
CHANGED
@@ -1,75 +1 @@
|
|
1
|
-
|
2
|
-
require 'logger'
|
3
|
-
require 'fileutils'
|
4
|
-
require 'em-websocket'
|
5
|
-
$:.unshift(File.dirname(__FILE__))
|
6
|
-
require 'em-websocket_hacks'
|
7
|
-
|
8
|
-
# Socky is a WebSocket server and client for Ruby on Rails
|
9
|
-
# @author Bernard "Imanel" Potocki
|
10
|
-
# @see http://github.com/imanel/socky_gem main repository
|
11
|
-
module Socky
|
12
|
-
|
13
|
-
class SockyError < StandardError; end #:nodoc:
|
14
|
-
|
15
|
-
# server version
|
16
|
-
VERSION = File.read(File.dirname(__FILE__) + '/../VERSION').strip
|
17
|
-
|
18
|
-
class << self
|
19
|
-
# read server-wide options
|
20
|
-
def options
|
21
|
-
@options ||= {}
|
22
|
-
end
|
23
|
-
|
24
|
-
# write server-wide options
|
25
|
-
def options=(val)
|
26
|
-
@options = val
|
27
|
-
end
|
28
|
-
|
29
|
-
# access or initialize logger
|
30
|
-
# default logger writes to STDOUT
|
31
|
-
def logger
|
32
|
-
return @logger if defined?(@logger) && !@logger.nil?
|
33
|
-
path = log_path
|
34
|
-
FileUtils.mkdir_p(File.dirname(path))
|
35
|
-
prepare_logger(path)
|
36
|
-
rescue
|
37
|
-
prepare_logger(STDOUT)
|
38
|
-
end
|
39
|
-
|
40
|
-
# overwrite default logger
|
41
|
-
def logger=(logger)
|
42
|
-
@logger = logger
|
43
|
-
end
|
44
|
-
|
45
|
-
# default log path
|
46
|
-
def log_path
|
47
|
-
options[:log_path] || nil
|
48
|
-
end
|
49
|
-
|
50
|
-
# default pid path
|
51
|
-
def pid_path
|
52
|
-
options[:pid_path] || File.join(%w( / var run socky.pid ))
|
53
|
-
end
|
54
|
-
|
55
|
-
# default config path
|
56
|
-
def config_path
|
57
|
-
options[:config_path] || File.join(%w( / var run socky.yml ))
|
58
|
-
end
|
59
|
-
|
60
|
-
private
|
61
|
-
|
62
|
-
def prepare_logger(output)
|
63
|
-
@logger = Logger.new(output)
|
64
|
-
@logger.level = Logger::INFO unless options[:debug]
|
65
|
-
@logger
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
require 'socky/misc'
|
71
|
-
require 'socky/options'
|
72
|
-
require 'socky/runner'
|
73
|
-
require 'socky/connection'
|
74
|
-
require 'socky/net_request'
|
75
|
-
require 'socky/message'
|
1
|
+
# Placeholder
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: socky
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 4
|
9
|
+
- 0
|
10
|
+
version: 0.4.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Bernard Potocki
|
@@ -15,97 +15,39 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-10-
|
19
|
-
default_executable:
|
18
|
+
date: 2010-10-28 00:00:00 +02:00
|
19
|
+
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
|
-
name:
|
22
|
+
name: socky-server
|
23
23
|
prerelease: false
|
24
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
hash:
|
29
|
+
hash: 15
|
30
30
|
segments:
|
31
31
|
- 0
|
32
|
-
- 1
|
33
32
|
- 4
|
34
|
-
version: 0.1.4
|
35
|
-
type: :runtime
|
36
|
-
version_requirements: *id001
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: em-http-request
|
39
|
-
prerelease: false
|
40
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ">="
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
hash: 3
|
46
|
-
segments:
|
47
|
-
- 0
|
48
|
-
version: "0"
|
49
|
-
type: :runtime
|
50
|
-
version_requirements: *id002
|
51
|
-
- !ruby/object:Gem::Dependency
|
52
|
-
name: json
|
53
|
-
prerelease: false
|
54
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
55
|
-
none: false
|
56
|
-
requirements:
|
57
|
-
- - ">="
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
hash: 3
|
60
|
-
segments:
|
61
33
|
- 0
|
62
|
-
version:
|
34
|
+
version: 0.4.0
|
63
35
|
type: :runtime
|
64
|
-
version_requirements: *
|
65
|
-
description:
|
66
|
-
email:
|
67
|
-
executables:
|
68
|
-
|
36
|
+
version_requirements: *id001
|
37
|
+
description: Transitional package for socky-server gem
|
38
|
+
email: bernard.potocki@imanel.org
|
39
|
+
executables: []
|
40
|
+
|
69
41
|
extensions: []
|
70
42
|
|
71
43
|
extra_rdoc_files:
|
72
44
|
- README.textile
|
73
45
|
files:
|
74
|
-
-
|
46
|
+
- .gitignore
|
75
47
|
- README.textile
|
76
|
-
- Rakefile
|
77
|
-
- VERSION
|
78
|
-
- bin/socky
|
79
|
-
- lib/em-websocket_hacks.rb
|
80
48
|
- lib/socky.rb
|
81
|
-
- lib/socky/connection.rb
|
82
|
-
- lib/socky/connection/authentication.rb
|
83
|
-
- lib/socky/connection/finders.rb
|
84
|
-
- lib/socky/message.rb
|
85
|
-
- lib/socky/misc.rb
|
86
|
-
- lib/socky/net_request.rb
|
87
|
-
- lib/socky/options.rb
|
88
|
-
- lib/socky/options/config.rb
|
89
|
-
- lib/socky/options/parser.rb
|
90
|
-
- lib/socky/runner.rb
|
91
|
-
- spec/em-websocket_spec.rb
|
92
|
-
- spec/files/default.yml
|
93
|
-
- spec/files/invalid.yml
|
94
|
-
- spec/socky/connection/authentication_spec.rb
|
95
|
-
- spec/socky/connection/finders_spec.rb
|
96
|
-
- spec/socky/connection_spec.rb
|
97
|
-
- spec/socky/message_spec.rb
|
98
|
-
- spec/socky/misc_spec.rb
|
99
|
-
- spec/socky/net_request_spec.rb
|
100
|
-
- spec/socky/options/config_spec.rb
|
101
|
-
- spec/socky/options/parser_spec.rb
|
102
|
-
- spec/socky/options_spec.rb
|
103
|
-
- spec/socky/runner_spec.rb
|
104
|
-
- spec/socky_spec.rb
|
105
|
-
- spec/spec_helper.rb
|
106
|
-
- spec/support/stallion.rb
|
107
49
|
has_rdoc: true
|
108
|
-
homepage: http://github.com/
|
50
|
+
homepage: http://github.com/socky/socky-server-ruby
|
109
51
|
licenses: []
|
110
52
|
|
111
53
|
post_install_message:
|
@@ -137,19 +79,6 @@ rubyforge_project:
|
|
137
79
|
rubygems_version: 1.3.7
|
138
80
|
signing_key:
|
139
81
|
specification_version: 3
|
140
|
-
summary:
|
141
|
-
test_files:
|
142
|
-
|
143
|
-
- spec/socky/connection/authentication_spec.rb
|
144
|
-
- spec/socky/connection/finders_spec.rb
|
145
|
-
- spec/socky/connection_spec.rb
|
146
|
-
- spec/socky/message_spec.rb
|
147
|
-
- spec/socky/misc_spec.rb
|
148
|
-
- spec/socky/net_request_spec.rb
|
149
|
-
- spec/socky/options/config_spec.rb
|
150
|
-
- spec/socky/options/parser_spec.rb
|
151
|
-
- spec/socky/options_spec.rb
|
152
|
-
- spec/socky/runner_spec.rb
|
153
|
-
- spec/socky_spec.rb
|
154
|
-
- spec/spec_helper.rb
|
155
|
-
- spec/support/stallion.rb
|
82
|
+
summary: Transitional package for socky-server gem
|
83
|
+
test_files: []
|
84
|
+
|
data/CHANGELOG.textile
DELETED
@@ -1,88 +0,0 @@
|
|
1
|
-
h1. Changelog
|
2
|
-
|
3
|
-
h2. 0.2.1 / 2010-10-09
|
4
|
-
|
5
|
-
* new features:
|
6
|
-
** default config should have subscribe url's commented out for starting users
|
7
|
-
* bugfixes:
|
8
|
-
** show sent messages in true form instead of "inspect" one
|
9
|
-
|
10
|
-
h2. 0.2.0 / 2010-10-03
|
11
|
-
|
12
|
-
* new features:
|
13
|
-
** inline documentation
|
14
|
-
* bugfixes:
|
15
|
-
** send authentication after finishing handshake
|
16
|
-
** tests less using stubs and more real cases
|
17
|
-
** fix some tests
|
18
|
-
|
19
|
-
h2. 0.1.3 / 2010-09-23
|
20
|
-
|
21
|
-
* new features:
|
22
|
-
** none
|
23
|
-
* bugfixes:
|
24
|
-
** fix query :show_connections in ruby 1.9
|
25
|
-
** fix user authentication when url subscribe/unsubscribe is disabled
|
26
|
-
|
27
|
-
h2. 0.1.2 / 2010-09-21
|
28
|
-
|
29
|
-
* new features:
|
30
|
-
** none
|
31
|
-
* bugfixes:
|
32
|
-
** fix routes to spec_helper in ruby 1.9.2
|
33
|
-
** ruby 1.9 will no longer raise errors on String to_a call
|
34
|
-
|
35
|
-
h2. 0.1.1 / 2010-08-25
|
36
|
-
|
37
|
-
* new features:
|
38
|
-
** socky has now support for signed certificates by :tls_options config option
|
39
|
-
* bugfixes:
|
40
|
-
** none
|
41
|
-
|
42
|
-
h2. 0.1.0 / 2010-08-03
|
43
|
-
|
44
|
-
*IMPORTANT! This version will not work with plugin version lower than 0.1.0*
|
45
|
-
|
46
|
-
* new features:
|
47
|
-
** server now send authentication status
|
48
|
-
** new syntax
|
49
|
-
** option to exclude clients/channels
|
50
|
-
* bugfixes:
|
51
|
-
** none
|
52
|
-
|
53
|
-
h2. 0.0.9 / 2010-06-20
|
54
|
-
|
55
|
-
*IMPORTANT! This version will not work with plugin version lower than 0.0.9*
|
56
|
-
|
57
|
-
* new features:
|
58
|
-
** support for next version of em-websocket debug options(based on mloughran branch)
|
59
|
-
** support for websocket draft 76
|
60
|
-
** support for wss/SSL connections
|
61
|
-
** socky can now be started in 'daemon' mode
|
62
|
-
** socky now sending all messages in JSON format
|
63
|
-
* bugfixes:
|
64
|
-
** socky will no longer crash when when request query is invalid - i.e. chrome 6.0.*(with websocket draft76) and em-websocket 0.0.6
|
65
|
-
|
66
|
-
h2. 0.0.8 / 2010-06-06
|
67
|
-
|
68
|
-
* new features:
|
69
|
-
** full rspec suite
|
70
|
-
** allow admin param to be both "1" and "true"
|
71
|
-
* bugfixes:
|
72
|
-
** proper configuration options parsing order
|
73
|
-
** rescue from invalid config file
|
74
|
-
** rescue from invalid args
|
75
|
-
** symbolize_keys will no longer raise error if argument is not hash
|
76
|
-
** modules will no longer depend on parent class
|
77
|
-
** message will no longer raise exeption is JSON is invalid
|
78
|
-
|
79
|
-
h2. 0.0.7 / 2010-05-25
|
80
|
-
|
81
|
-
* new features:
|
82
|
-
** user authentication is now async
|
83
|
-
* bugfixes:
|
84
|
-
** server will no longer fail when starting from source instead of gem
|
85
|
-
|
86
|
-
h2. 0.0.6 / 2010-05-24
|
87
|
-
|
88
|
-
* initial release
|
data/Rakefile
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'rake'
|
2
|
-
require 'rake/clean'
|
3
|
-
CLEAN.include %w(**/*.{log,rbc})
|
4
|
-
|
5
|
-
require 'spec/rake/spectask'
|
6
|
-
|
7
|
-
task :default => :spec
|
8
|
-
|
9
|
-
Spec::Rake::SpecTask.new do |t|
|
10
|
-
t.ruby_opts = ['-rtest/unit']
|
11
|
-
t.spec_files = FileList['spec/**/*_spec.rb']
|
12
|
-
end
|
13
|
-
|
14
|
-
begin
|
15
|
-
require 'jeweler'
|
16
|
-
Jeweler::Tasks.new do |gemspec|
|
17
|
-
gemspec.name = "socky"
|
18
|
-
gemspec.summary = "Socky is a WebSocket server and client for Ruby on Rails"
|
19
|
-
gemspec.description = "Socky is a WebSocket server and client for Ruby on Rails"
|
20
|
-
gemspec.email = "b.potocki@imanel.org"
|
21
|
-
gemspec.homepage = "http://github.com/imanel/socky_gem"
|
22
|
-
gemspec.authors = ["Bernard Potocki"]
|
23
|
-
gemspec.add_dependency('em-websocket', '>= 0.1.4')
|
24
|
-
gemspec.add_dependency('em-http-request')
|
25
|
-
gemspec.add_dependency('json')
|
26
|
-
gemspec.files.exclude ".gitignore"
|
27
|
-
end
|
28
|
-
rescue LoadError
|
29
|
-
puts "Jeweler not available. Install it with: gem install jeweler"
|
30
|
-
end
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.2.1
|
data/bin/socky
DELETED
data/lib/em-websocket_hacks.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
if defined?(EventMachine::WebSocket::Debugger)
|
2
|
-
klass = EventMachine::WebSocket::Debugger
|
3
|
-
else
|
4
|
-
klass = EventMachine::WebSocket::Connection
|
5
|
-
end
|
6
|
-
|
7
|
-
klass.class_eval do
|
8
|
-
|
9
|
-
def debug(*data)
|
10
|
-
if @debug
|
11
|
-
Socky.logger.debug "Socket " + data.flatten.collect{|line| line.to_s.gsub("\r\n","\n").gsub("\n","\\n")}.join(" ")
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
end
|
data/lib/socky/connection.rb
DELETED
@@ -1,137 +0,0 @@
|
|
1
|
-
require 'json'
|
2
|
-
require 'socky/connection/authentication'
|
3
|
-
require 'socky/connection/finders'
|
4
|
-
|
5
|
-
module Socky
|
6
|
-
# every connection to server creates one instance of Connection
|
7
|
-
class Connection
|
8
|
-
include Socky::Misc
|
9
|
-
include Socky::Connection::Authentication
|
10
|
-
extend Socky::Connection::Finders
|
11
|
-
|
12
|
-
# reference to connection socket
|
13
|
-
attr_reader :socket
|
14
|
-
|
15
|
-
class << self
|
16
|
-
# list of all connections in pool
|
17
|
-
# @return [Array] list of connections
|
18
|
-
def connections
|
19
|
-
@connections ||= []
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
# initialize new connection
|
24
|
-
# @param [WebSocket] socket valid connection socket
|
25
|
-
def initialize(socket)
|
26
|
-
@socket = socket
|
27
|
-
end
|
28
|
-
|
29
|
-
# read query data from socket request
|
30
|
-
# @return [Hash] hash of query data
|
31
|
-
def query
|
32
|
-
socket.request["Query"] || {}
|
33
|
-
end
|
34
|
-
|
35
|
-
# return if user appear to be admin
|
36
|
-
# this one should not be base to imply that user actually is
|
37
|
-
# admin - later authentication is needed
|
38
|
-
# @return [Boolean] is user claim to be admin?
|
39
|
-
def admin
|
40
|
-
["true","1"].include?(query["admin"])
|
41
|
-
end
|
42
|
-
|
43
|
-
# client individual id - multiple connection can be organized
|
44
|
-
# by client id and later accessed at once
|
45
|
-
# @return [String] client id(might be nil)
|
46
|
-
def client
|
47
|
-
query["client_id"]
|
48
|
-
end
|
49
|
-
|
50
|
-
# client individual secret - used to check if user is admin
|
51
|
-
# and to sending authentication data to server(by subscribe_url)
|
52
|
-
# @return [String] client secret(might be nil)
|
53
|
-
def secret
|
54
|
-
query["client_secret"]
|
55
|
-
end
|
56
|
-
|
57
|
-
# client channel list - one client can have multiple channels
|
58
|
-
# every client have at last channel - if no channels are provided
|
59
|
-
# at default then user is assigned to nil channel
|
60
|
-
# @return [Array] list of client channels
|
61
|
-
def channels
|
62
|
-
@channels ||= query["channels"].to_s.split(",").collect(&:strip).reject(&:empty?)
|
63
|
-
@channels[0] ||= nil # Every user should have at last one channel
|
64
|
-
@channels
|
65
|
-
end
|
66
|
-
|
67
|
-
# check if client is valid and add him to pool or disconnect
|
68
|
-
def subscribe
|
69
|
-
debug [self.name, "incoming"]
|
70
|
-
subscribe_request
|
71
|
-
end
|
72
|
-
|
73
|
-
# remove client from pool and disconnect
|
74
|
-
def unsubscribe
|
75
|
-
debug [self.name, "terminated"]
|
76
|
-
unsubscribe_request
|
77
|
-
end
|
78
|
-
|
79
|
-
# check if client can send messages and process it
|
80
|
-
# @see Socky::Message.process
|
81
|
-
# @param [String] msg message to send in json format
|
82
|
-
def process_message(msg)
|
83
|
-
if admin && authenticated?
|
84
|
-
Socky::Message.process(self, msg)
|
85
|
-
else
|
86
|
-
self.send_message "You are not authorized to post messages"
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
# send message to client
|
91
|
-
# @param [Object] msg data to send(will be converted to json using to_json method)
|
92
|
-
def send_message(msg)
|
93
|
-
send_data({:type => :message, :body => msg})
|
94
|
-
end
|
95
|
-
|
96
|
-
# disconnect connection
|
97
|
-
def disconnect
|
98
|
-
socket.close_connection_after_writing
|
99
|
-
end
|
100
|
-
|
101
|
-
# convert connection to json(used in show_connection query)
|
102
|
-
# @param [Any] args it is required by different versions of ruby
|
103
|
-
# @return [JSon] id, client_id and channel list data
|
104
|
-
def to_json(*args)
|
105
|
-
{
|
106
|
-
:id => self.object_id,
|
107
|
-
:client_id => self.client,
|
108
|
-
:channels => self.channels.reject{|channel| channel.nil?}
|
109
|
-
}.to_json
|
110
|
-
end
|
111
|
-
|
112
|
-
private
|
113
|
-
|
114
|
-
def send_data(data)
|
115
|
-
json_data = data.to_json
|
116
|
-
debug [self.name, "sending data", json_data]
|
117
|
-
socket.send json_data
|
118
|
-
end
|
119
|
-
|
120
|
-
def connection_pool
|
121
|
-
self.class.connections
|
122
|
-
end
|
123
|
-
|
124
|
-
def in_connection_pool?
|
125
|
-
connection_pool.include?(self)
|
126
|
-
end
|
127
|
-
|
128
|
-
def add_to_pool
|
129
|
-
connection_pool << self unless self.admin || in_connection_pool?
|
130
|
-
end
|
131
|
-
|
132
|
-
def remove_from_pool
|
133
|
-
connection_pool.delete(self)
|
134
|
-
end
|
135
|
-
|
136
|
-
end
|
137
|
-
end
|