Class: Hector::UserSession

Inherits:
Session
  • Object
show all
Defined in:
lib/hector/user_session.rb

Constant Summary

Constants inherited from Session

Session::SESSIONS

Instance Attribute Summary collapse

Attributes inherited from Session

#away_message, #nickname, #request, #response

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Session

all, #away, #away?, #back, #broadcast, broadcast_to, #channel?, delete, #deliver, find, #find, #hostname, #name, nicknames, normalize, #receive, register, rename, #rename, reset!, #source, #who

Methods included from Commands::Invite

#on_invite

Methods included from Commands::Away

#on_away

Methods included from Commands::Whois

#on_whois, #respond_to_whois_for, #whois

Methods included from Commands::Who

#on_who, #sessions_for_who, #who

Methods included from Commands::Topic

#on_topic, #respond_to_topic

Methods included from Commands::Realname

#on_realname

Methods included from Commands::Quit

#on_quit

Methods included from Commands::Privmsg

#on_privmsg

Methods included from Commands::Pong

#on_pong

Methods included from Commands::Ping

#on_ping

Methods included from Commands::Part

#on_part

Methods included from Commands::Notice

#on_notice

Methods included from Commands::Nick

#on_nick

Methods included from Commands::Names

#on_names, #respond_to_names

Methods included from Commands::Mode

#on_mode

Methods included from Commands::Join

#on_join

Methods included from Concerns::Presence

#channels, #destroy_presence, included, #initialize_presence, #peer_sessions, #seconds_idle, #touch_presence

Methods included from Concerns::KeepAlive

#destroy_keep_alive, #initialize_keep_alive, #on_heartbeat

Constructor Details

#initialize(nickname, connection, identity, realname) ⇒ UserSession

Returns a new instance of UserSession.



15
16
17
18
19
20
21
22
# File 'lib/hector/user_session.rb', line 15

def initialize(nickname, connection, identity, realname)
  super(nickname)
  @connection = connection
  @identity   = identity
  @realname   = realname
  initialize_keep_alive
  initialize_presence
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



3
4
5
# File 'lib/hector/user_session.rb', line 3

def connection
  @connection
end

#identityObject (readonly)

Returns the value of attribute identity.



3
4
5
# File 'lib/hector/user_session.rb', line 3

def identity
  @identity
end

#realnameObject (readonly)

Returns the value of attribute realname.



3
4
5
# File 'lib/hector/user_session.rb', line 3

def realname
  @realname
end

Class Method Details

.create(nickname, connection, identity, realname) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/hector/user_session.rb', line 6

def create(nickname, connection, identity, realname)
  if find(nickname)
    raise NicknameInUse, nickname
  else
    register UserSession.new(nickname, connection, identity, realname)
  end
end

Instance Method Details

#destroyObject



24
25
26
27
28
# File 'lib/hector/user_session.rb', line 24

def destroy
  super
  destroy_presence
  destroy_keep_alive
end

#respond_withObject



30
31
32
# File 'lib/hector/user_session.rb', line 30

def respond_with(*)
  connection.respond_with(super)
end

#usernameObject



34
35
36
# File 'lib/hector/user_session.rb', line 34

def username
  identity.username
end