Class: SocketsController

Inherits:
ApplicationController show all
Includes:
ApplicationHelper, Rails, SocketsHelper
Defined in:
app/controllers/sockets_controller.rb

Overview

Copyright © 2010, Diaspora Inc. This file is

  licensed under the Affero General Public License version 3 or later.  See
  the COPYRIGHT file.

Instance Method Summary (collapse)

Methods included from SocketsHelper

#action_hash, #obj_id

Methods included from NotificationsHelper

#new_notification_link, #notification_message_for, #notification_people_link, #object_link, #peoples_names, #the_day, #the_month, #translation

Methods included from ApplicationHelper

#bookmarklet, #direction_for, #get_javascript_strings_for, #hard_link, #how_long_ago, #info_text, #mine?, #object_fields, #object_path, #owner_image_link, #owner_image_tag, #person_image_link, #person_image_tag, #person_link, #post_yield_tag, #profile_photo, #rtl?, #timeago, #type_partial

Methods inherited from ApplicationController

#after_sign_in_path_for, #clear_gc_stats, #ensure_http_referer_is_set, #ensure_page, #grammatical_gender, #redirect_unless_admin, #set_git_header, #set_grammatical_gender, #set_header_data, #set_invites, #set_locale, #which_action_and_user

Instance Method Details

- (Object) incoming(msg)



10
11
12
# File 'app/controllers/sockets_controller.rb', line 10

def incoming(msg)
  Rails.logger.info("Socket received connection to: #{msg}")
end

- (Object) outgoing(user_or_id, object, opts = {})



14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/sockets_controller.rb', line 14

def outgoing(user_or_id, object, opts={})
  if user_or_id.instance_of?(Fixnum)
    user_id = user_or_id
  else
    user_id = user_or_id.id
    @user = user_or_id
  end
  return unless Diaspora::WebSocket.is_connected?(user_id)
  @_request = ActionDispatch::Request.new({})
  Diaspora::WebSocket.queue_to_user(user_id, action_hash(@user || User.find(user_id), object, opts))
end