Module: ENet

Defined in:
lib/ffi-enet/renet.rb,
lib/ffi-enet/version.rb,
lib/ffi-enet/renet/client.rb,
lib/ffi-enet/renet/server.rb,
lib/ffi-enet/renet/connection.rb

Defined Under Namespace

Classes: Client, Connection, Server

Constant Summary collapse

VERSION =
"0.1.0"
@@initialized =
false
@@at_exit_handler =
false

Class Method Summary collapse

Class Method Details

.initObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/ffi-enet/renet.rb', line 9

def self.init
  return true if @@initialized

  return false if LibENet.enet_initialize != 0

  @@initialized = true

  unless @@at_exit_handler
    @@at_exit_handler = true

    at_exit do
      shutdown
    end
  end

  true
end

.shutdownObject



27
28
29
30
31
32
33
# File 'lib/ffi-enet/renet.rb', line 27

def self.shutdown
  return unless @@initialized

  LibENet.enet_deinitialize

  @@initialized = false
end