warchat 0.0.5 → 0.0.6
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.
- data/README.rdoc +4 -0
- data/lib/warchat.rb +0 -1
- data/lib/warchat/chat/client.rb +8 -7
- data/lib/warchat/chat/message.rb +2 -2
- data/lib/warchat/chat/presence.rb +1 -1
- data/lib/warchat/network/connection.rb +3 -3
- data/lib/warchat/network/session.rb +4 -4
- data/lib/warchat/timer.rb +2 -1
- data/lib/warchat/version.rb +1 -1
- data/warchat.gemspec +1 -1
- metadata +14 -12
data/README.rdoc
CHANGED
@@ -10,6 +10,10 @@ This project aims to create a simple ruby interface for connecting to Blizzard's
|
|
10
10
|
* Whispers
|
11
11
|
* Presence notifications
|
12
12
|
|
13
|
+
= Acknowledgements
|
14
|
+
|
15
|
+
A big thanks to Eike Siewertsen (http://www.github.com/fry), without whom this probably wouldn't be possible.
|
16
|
+
|
13
17
|
= Simple Usage example
|
14
18
|
|
15
19
|
This is a simple chat client that will let you talk in guild chat and receive messages.
|
data/lib/warchat.rb
CHANGED
data/lib/warchat/chat/client.rb
CHANGED
@@ -20,11 +20,11 @@ module Warchat
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def session_error response
|
23
|
-
on_fail.
|
23
|
+
on_fail and on_fail.call(response["body"]) if response.target == "/chat-login"
|
24
24
|
end
|
25
25
|
|
26
26
|
def session_establish response
|
27
|
-
on_establish.
|
27
|
+
on_establish and on_establish.call(response)
|
28
28
|
end
|
29
29
|
|
30
30
|
def session_receive response
|
@@ -44,8 +44,8 @@ module Warchat
|
|
44
44
|
|
45
45
|
def chat_logout response
|
46
46
|
puts 'Logged out of chat'
|
47
|
-
@timer.
|
48
|
-
on_chat_logout.
|
47
|
+
@timer and @timer.stop
|
48
|
+
on_chat_logout and on_chat_logout.call response
|
49
49
|
session.close
|
50
50
|
end
|
51
51
|
|
@@ -60,10 +60,11 @@ module Warchat
|
|
60
60
|
|
61
61
|
elsif response.message?
|
62
62
|
message = Message.new(response)
|
63
|
-
on_message.
|
64
|
-
|
63
|
+
on_message and on_message.call(message)
|
64
|
+
m = "on_message_#{message.type}".to_sym
|
65
|
+
send(m) and send(m).call(message)
|
65
66
|
elsif response.presence?
|
66
|
-
on_presence.
|
67
|
+
on_presence and on_presence.call(Presence.new(response))
|
67
68
|
else
|
68
69
|
puts "unhandled chat type: #{response.chat_type}"
|
69
70
|
end
|
data/lib/warchat/chat/message.rb
CHANGED
@@ -25,11 +25,11 @@ module Warchat
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def character_name
|
28
|
-
@character_id.
|
28
|
+
@character_id and @character_id.split(':')[-2]
|
29
29
|
end
|
30
30
|
|
31
31
|
def realm_id
|
32
|
-
@character_id.
|
32
|
+
@character_id and @character_id.split(':').last
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
@@ -32,7 +32,7 @@ module Warchat
|
|
32
32
|
def close reason = ""
|
33
33
|
return if is_closed?
|
34
34
|
|
35
|
-
on_close.
|
35
|
+
on_close and on_close.call(reason)
|
36
36
|
|
37
37
|
@mutex.synchronize do
|
38
38
|
@closed = true
|
@@ -54,7 +54,7 @@ module Warchat
|
|
54
54
|
def handle_responses
|
55
55
|
until is_closed?
|
56
56
|
response = Response.new(@socket)
|
57
|
-
on_receive.
|
57
|
+
on_receive and on_receive.call(response) unless is_closed?
|
58
58
|
sleep 0.01
|
59
59
|
end
|
60
60
|
rescue Exception => e
|
@@ -71,7 +71,7 @@ module Warchat
|
|
71
71
|
unless is_closed?
|
72
72
|
request.stream @socket
|
73
73
|
@socket.flush
|
74
|
-
on_send.
|
74
|
+
on_send and on_send.call(request)
|
75
75
|
end
|
76
76
|
end
|
77
77
|
end
|
@@ -50,7 +50,7 @@ module Warchat
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def send_request request
|
53
|
-
@connection.
|
53
|
+
@connection and @connection.send_request(request)
|
54
54
|
end
|
55
55
|
|
56
56
|
def stage_1 response
|
@@ -64,13 +64,13 @@ module Warchat
|
|
64
64
|
|
65
65
|
def stage_3 response
|
66
66
|
@established = true
|
67
|
-
on_establish.
|
67
|
+
on_establish and on_establish.call(response)
|
68
68
|
end
|
69
69
|
|
70
70
|
def connection_receive response
|
71
71
|
m = "stage_#{response['stage']}".to_sym
|
72
72
|
if response.ok?
|
73
|
-
respond_to? m and send(m,response) or on_receive.
|
73
|
+
respond_to? m and send(m,response) or on_receive and on_receive.call(response)
|
74
74
|
else
|
75
75
|
error = response["body"]
|
76
76
|
puts("error: " + error)
|
@@ -79,7 +79,7 @@ module Warchat
|
|
79
79
|
end
|
80
80
|
|
81
81
|
def connection_close reason
|
82
|
-
on_close.
|
82
|
+
on_close and on_close.call(reason)
|
83
83
|
end
|
84
84
|
end
|
85
85
|
end
|
data/lib/warchat/timer.rb
CHANGED
data/lib/warchat/version.rb
CHANGED
data/warchat.gemspec
CHANGED
@@ -14,8 +14,8 @@ Gem::Specification.new do |s|
|
|
14
14
|
|
15
15
|
s.rubyforge_project = "warchat"
|
16
16
|
|
17
|
+
s.add_dependency('i18n','>= 0.5.0')
|
17
18
|
s.add_dependency('activesupport','>= 3.0.0')
|
18
|
-
s.add_dependency('andand')
|
19
19
|
|
20
20
|
s.files = `git ls-files`.split("\n")
|
21
21
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: warchat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 19
|
5
|
+
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 6
|
10
|
+
version: 0.0.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Zachary Gavin
|
@@ -19,33 +19,35 @@ date: 2011-05-16 00:00:00 -04:00
|
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
|
-
name:
|
22
|
+
name: i18n
|
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: 11
|
30
30
|
segments:
|
31
|
-
- 3
|
32
31
|
- 0
|
32
|
+
- 5
|
33
33
|
- 0
|
34
|
-
version:
|
34
|
+
version: 0.5.0
|
35
35
|
type: :runtime
|
36
36
|
version_requirements: *id001
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
|
-
name:
|
38
|
+
name: activesupport
|
39
39
|
prerelease: false
|
40
40
|
requirement: &id002 !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
42
42
|
requirements:
|
43
43
|
- - ">="
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
hash:
|
45
|
+
hash: 7
|
46
46
|
segments:
|
47
|
+
- 3
|
47
48
|
- 0
|
48
|
-
|
49
|
+
- 0
|
50
|
+
version: 3.0.0
|
49
51
|
type: :runtime
|
50
52
|
version_requirements: *id002
|
51
53
|
description: "A simple interface to World of Warcraft Remote Guild Chat in Ruby. Supports whispers, guild chat, officer chat, and presence notifications. Many thanks to Eike Siewertsen (https://github.com/fry) for his work deciphering the protocol. "
|
@@ -108,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
110
|
requirements: []
|
109
111
|
|
110
112
|
rubyforge_project: warchat
|
111
|
-
rubygems_version: 1.
|
113
|
+
rubygems_version: 1.3.7
|
112
114
|
signing_key:
|
113
115
|
specification_version: 3
|
114
116
|
summary: A simple interface to World of Warcraft Remote Guild Chat based off Eike Siewertsen's C# implementation
|