Class: MurmurIce::Server
- Inherits:
-
Object
- Object
- MurmurIce::Server
- Defined in:
- lib/murmur-ice.rb
Overview
Meta
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#interface ⇒ Object
readonly
Returns the value of attribute interface.
Instance Method Summary collapse
-
#[](key) ⇒ Object
Return config key.
-
#[]=(key, val) ⇒ Object
Set config key.
-
#config ⇒ Object
Return all server config.
-
#get_uptime ⇒ Object
Return server uptime.
-
#get_users ⇒ Object
Get users.
-
#initialize(host, meta, id = nil, interface = nil) ⇒ Server
constructor
A new instance of Server.
-
#is_running? ⇒ Boolean
Return server status (true or false).
-
#kick_user!(session_id, reason = "Kicked by mysterious admin !") ⇒ Object
Kick user.
-
#restart! ⇒ Object
Restart server.
-
#start! ⇒ Object
Start server.
-
#stop! ⇒ Object
Stop server.
Constructor Details
#initialize(host, meta, id = nil, interface = nil) ⇒ Server
Returns a new instance of Server.
101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/murmur-ice.rb', line 101 def initialize(host, , id=nil, interface=nil) @host, = host, raise "You need to specify a server ID or an interface" if id.nil? && interface.nil? unless interface.nil? @interface = interface else @interface = .getServer(id) raise MurmurIce::InvalidServerException if @interface.nil? end @id = @interface.id end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
99 100 101 |
# File 'lib/murmur-ice.rb', line 99 def id @id end |
#interface ⇒ Object (readonly)
Returns the value of attribute interface.
99 100 101 |
# File 'lib/murmur-ice.rb', line 99 def interface @interface end |
Instance Method Details
#[](key) ⇒ Object
Return config key
161 162 163 |
# File 'lib/murmur-ice.rb', line 161 def [](key) return config[key.to_s] end |
#[]=(key, val) ⇒ Object
Set config key
168 169 170 171 |
# File 'lib/murmur-ice.rb', line 168 def []=(key, val) @interface.setConf(key.to_s, val.to_s) @config = nil end |
#config ⇒ Object
Return all server config
154 155 156 |
# File 'lib/murmur-ice.rb', line 154 def config @config = .getDefaultConf.merge(@interface.getAllConf) end |
#get_uptime ⇒ Object
Return server uptime
125 126 127 |
# File 'lib/murmur-ice.rb', line 125 def get_uptime return @interface.getUptime end |
#get_users ⇒ Object
Get users
176 177 178 |
# File 'lib/murmur-ice.rb', line 176 def get_users return @interface.getUsers end |
#is_running? ⇒ Boolean
Return server status (true or false)
118 119 120 |
# File 'lib/murmur-ice.rb', line 118 def is_running? return @interface.isRunning end |
#kick_user!(session_id, reason = "Kicked by mysterious admin !") ⇒ Object
Kick user
183 184 185 |
# File 'lib/murmur-ice.rb', line 183 def kick_user!(session_id, reason="Kicked by mysterious admin !") @interface.kickUser(session_id, reason.to_s) end |
#restart! ⇒ Object
Restart server
146 147 148 149 |
# File 'lib/murmur-ice.rb', line 146 def restart! if is_running? then stop! end start! end |
#start! ⇒ Object
Start server
132 133 134 |
# File 'lib/murmur-ice.rb', line 132 def start! @interface.start end |
#stop! ⇒ Object
Stop server
139 140 141 |
# File 'lib/murmur-ice.rb', line 139 def stop! @interface.stop end |