Class: IRC::Server::Client

Inherits:
Object show all
Defined in:
lib/failirc/server/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server, socket, listen = nil) ⇒ Client

Returns a new instance of Client.



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
# File 'lib/failirc/server/client.rb', line 34

def initialize (server, socket, listen=nil)
    @server = server
    @socket = socket
    @listen = listen

    @registered = false

    @channels = Channels.new(@server)
    @modes    = Modes.new

    if socket.is_a?(Mask)
        @mask = socket
    else
        @mask     = Mask.new
        self.host = socket.peeraddr[2]
        @ip       = socket.peeraddr[3]
        @port     = socket.addr[1]

        if socket.is_a?(OpenSSL::SSL::SSLSocket)
            @modes[:ssl] = true
        end
    end

    @connectedOn = Time.now
end

Instance Attribute Details

#channelsObject (readonly)

Returns the value of attribute channels.



31
32
33
# File 'lib/failirc/server/client.rb', line 31

def channels
  @channels
end

#connectedOnObject (readonly)

Returns the value of attribute connectedOn.



31
32
33
# File 'lib/failirc/server/client.rb', line 31

def connectedOn
  @connectedOn
end

#hostObject

Returns the value of attribute host.



31
32
33
# File 'lib/failirc/server/client.rb', line 31

def host
  @host
end

#ipObject (readonly)

Returns the value of attribute ip.



31
32
33
# File 'lib/failirc/server/client.rb', line 31

def ip
  @ip
end

#listenObject (readonly)

Returns the value of attribute listen.



31
32
33
# File 'lib/failirc/server/client.rb', line 31

def listen
  @listen
end

#maskObject (readonly)

Returns the value of attribute mask.



31
32
33
# File 'lib/failirc/server/client.rb', line 31

def mask
  @mask
end

#modesObject (readonly)

Returns the value of attribute modes.



31
32
33
# File 'lib/failirc/server/client.rb', line 31

def modes
  @modes
end

#nickObject

Returns the value of attribute nick.



31
32
33
# File 'lib/failirc/server/client.rb', line 31

def nick
  @nick
end

#passwordObject

Returns the value of attribute password.



32
33
34
# File 'lib/failirc/server/client.rb', line 32

def password
  @password
end

#portObject (readonly)

Returns the value of attribute port.



31
32
33
# File 'lib/failirc/server/client.rb', line 31

def port
  @port
end

#realNameObject

Returns the value of attribute realName.



32
33
34
# File 'lib/failirc/server/client.rb', line 32

def realName
  @realName
end

#serverObject (readonly)

Returns the value of attribute server.



31
32
33
# File 'lib/failirc/server/client.rb', line 31

def server
  @server
end

#socketObject (readonly)

Returns the value of attribute socket.



31
32
33
# File 'lib/failirc/server/client.rb', line 31

def socket
  @socket
end

#userObject

Returns the value of attribute user.



31
32
33
# File 'lib/failirc/server/client.rb', line 31

def user
  @user
end

Instance Method Details

#inspectObject



93
94
95
# File 'lib/failirc/server/client.rb', line 93

def inspect
    return "#<Client: #{mask} #{modes}#{(modes[:registered]) ? ' registered' : ''}>"
end

#numeric(response, value = nil) ⇒ Object



85
86
87
# File 'lib/failirc/server/client.rb', line 85

def numeric (response, value=nil)
    raw ":#{server.host} #{'%03d' % response[:code]} #{nick || 'faggot'} #{eval(response[:text])}"
end

#raw(text) ⇒ Object



80
81
82
83
# File 'lib/failirc/server/client.rb', line 80

def raw (text)
    @server.dispatcher.dispatch :output, self, text
    @server.dispatcher.connection.output.push @socket, text
end

#send(symbol, *args) ⇒ Object



72
73
74
75
76
77
78
# File 'lib/failirc/server/client.rb', line 72

def send (symbol, *args)
    begin
        self.method(symbol).call(*args)
    rescue Exception => e
        self.debug e
    end
end

#to_sObject



89
90
91
# File 'lib/failirc/server/client.rb', line 89

def to_s
    mask.to_s
end