Class: Net::IRC::Server::Session

### Home Classes Methods

### In Files

- lib/net/irc/server.rb

### Parent

Object

### Methods

- ::new
- ::start
- #available_channel_modes
- #available_user_modes
- #finish
- #method_missing
- #on_connected
- #on_disconnected
- #on_message
- #on_nick
- #on_pass
- #on_ping
- #on_user
- #server_name
- #server_version
- #start

### Included Modules

- Net::IRC

### Files

- README

### Class/Module Index

Quicksearch

- Net
- Net::IRC
- Net::IRC::Client
- Net::IRC::Client::ChannelManager
- Net::IRC::IRCException
- Net::IRC::Message
- Net::IRC::Message::InvalidMessage
- Net::IRC::Message::ModeParser
- Net::IRC::Message::ServerConfig
- Net::IRC::Prefix
- Net::IRC::Server
- Net::IRC::Server::Session
- Object

No matching classes.

# Net::IRC::Server::Session

### Attributes

host[R]
nick[R]
prefix[R]
real[R]

### Public Class Methods

new(server, socket, logger, opts={}) click to toggle source

    # File lib/net/irc/server.rb, line 81
    def initialize(server, socket, logger, opts={})
            @server, @socket, @log, @opts = server, socket, logger, opts
    end

start(*args) click to toggle source

    # File lib/net/irc/server.rb, line 85
    def self.start(*args)
            new(*args).start
    end

### Public Instance Methods

available_channel_modes() click to toggle source

Override subclass.

    # File lib/net/irc/server.rb, line 77
    def available_channel_modes
            "spknm"
    end

available_user_modes() click to toggle source

Override subclass.

    # File lib/net/irc/server.rb, line 72
    def available_user_modes
            "eixwy"
    end

finish() click to toggle source

Close this session.

    # File lib/net/irc/server.rb, line 112
    def finish
            begin
                    @socket.close
            rescue
            end
            on_disconnected
    end

method_missing(name, *args) click to toggle source

Do nothing. This is for avoiding error on calling super. So you can always call super at subclass.

    # File lib/net/irc/server.rb, line 164
    def method_missing(name, *args)
    end

on_connected() click to toggle source

Call when socket connected.

    # File lib/net/irc/server.rb, line 144
    def on_connected
    end

on_disconnected() click to toggle source

Call when socket closed.

    # File lib/net/irc/server.rb, line 148
    def on_disconnected
    end

on_message(m) click to toggle source

Catch all messages. If this method return true, aother callback will not be called.

    # File lib/net/irc/server.rb, line 153
    def on_message(m)
    end

on_nick(m) click to toggle source

Default NICK callback. Set @nick.

    # File lib/net/irc/server.rb, line 128
    def on_nick(m)
            @nick = m.params[0]
            @prefix = Prefix.new("#{@nick}!#{@user}@#{@host}") if defined? @prefix
    end

on_pass(m) click to toggle source

Default PASS callback. Set @pass.

    # File lib/net/irc/server.rb, line 122
    def on_pass(m)
            @pass = m.params[0]
    end

on_ping(m) click to toggle source

Default PING callback. Response PONG.

    # File lib/net/irc/server.rb, line 157
    def on_ping(m)
            post server_name, PONG, m.params[0]
    end

on_user(m) click to toggle source

Default USER callback. Set @user, @real, @host and call initial_message.

    # File lib/net/irc/server.rb, line 135
    def on_user(m)
            @user, @real = m.params[0], m.params[3]
            @nick ||= @user
            @host = @socket.peeraddr[2]
            @prefix = Prefix.new("#{@nick}!#{@user}@#{@host}")
            initial_message
    end

server_name() click to toggle source

Override subclass.

    # File lib/net/irc/server.rb, line 62
    def server_name
            "net-irc"
    end

server_version() click to toggle source

Override subclass.

    # File lib/net/irc/server.rb, line 67
    def server_version
            "0.0.0"
    end

start() click to toggle source

Start session loop.

    # File lib/net/irc/server.rb, line 90
    def start
            on_connected
            while l = @socket.gets
                    begin
                            @log.debug "RECEIVE: #{l.chomp}"
                            m = Message.parse(l)
                            next if on_message(m) === true

                            name = "on_#{(COMMANDS[m.command.upcase] || m.command).downcase}"
                            send(name, m) if respond_to?(name)

                            break if m.command == QUIT
                    rescue Message::InvalidMessage
                            @log.error "MessageParse: " + l.inspect
                    end
            end
    rescue IOError
    ensure
            finish
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.