29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/twterm/streaming_client.rb', line 29
def initialize_user_stream
return if user_stream_initialized?
streaming_client.on_friends do
user_stream_connected!
end
streaming_client.on_timeline_status do ||
status = Status.new()
publish(Event::Status::Timeline.new(status))
publish(Event::Status::Mention.new(status)) if status.text.include?('@%s' % screen_name)
end
streaming_client.on_delete do |status_id|
publish(Event::StatusDeleted.new(status_id))
end
streaming_client.on_event(:favorite) do |event|
user = User.new(Twitter::User.new(event[:source]))
status = Status.new(Twitter::Status.new(event[:target_object]))
event = Event::Favorite.new(user, status, self)
publish(event)
end
streaming_client.on_event(:follow) do |event|
source = User.new(Twitter::User.new(event[:source]))
target = User.new(Twitter::User.new(event[:target]))
event = Event::Follow.new(source, target, self)
publish(:followed, event)
end
streaming_client.on_no_data_received do
user_stream_disconnected!
connect_user_stream
end
user_stream_initialized!
end
|