Class: GamesAndRpgParadise::Mud::Client
- Inherits:
-
Base
- Object
- Base
- GamesAndRpgParadise::Mud::Client
show all
- Includes:
- FileUtils::Verbose
- Defined in:
- lib/games_and_rpg_paradise/mud/client/client.rb
Overview
Instance Method Summary
collapse
Methods inherited from Base
#find_adverb_for, #lang_wnum, #sentence, #word_wrap
Constructor Details
#initialize ⇒ Client
50
51
52
|
# File 'lib/games_and_rpg_paradise/mud/client/client.rb', line 50
def initialize
reset
end
|
Instance Method Details
#close_the_connection ⇒ Object
#
close_the_connection
This method is used to close the connection to the remote host again.
#
196
197
198
|
# File 'lib/games_and_rpg_paradise/mud/client/client.rb', line 196
def close_the_connection
@telnet_object.close
end
|
#display_with_token(i, token = '=') ⇒ Object
#
display_with_token
This method does cme with tokens.
#
145
146
147
148
149
|
# File 'lib/games_and_rpg_paradise/mud/client/client.rb', line 145
def display_with_token(i, token = '=')
e token * 80
e i
e token * 80
end
|
#do_cmd(i = 'l') ⇒ Object
#
do_cmd
Do perform the supplied command on the telnet-object via this method.
#
133
134
135
136
137
138
|
# File 'lib/games_and_rpg_paradise/mud/client/client.rb', line 133
def do_cmd(
i = 'l'
)
e "Doing command `#{i}` next."
@telnet_object.cmd(i) {|entry| print entry }
end
|
#do_connect_and_login ⇒ Object
Also known as:
do_login
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
|
# File 'lib/games_and_rpg_paradise/mud/client/client.rb', line 154
def do_connect_and_login
e
e 'Trying to Init the telnet-object next ...'
e
@telnet_object = Net::Telnet::new({
'Host' => host_uri?,
'Port' => host_port?,
'Password' => password?,
'Prompt' => /[$%#>] \z/n,
'Timeout' => 30
}) { |return_msg|
display_with_token("Return Message: #{return_msg}")
}
display_with_token('Init Object finished.')
@telnet_object.login(@login_name, @login_password) { |entry|
print entry
}
e 'Continuation ...'
@telnet_object.cmd('look')
close_the_connection
end
|
#host_port? ⇒ Boolean
83
84
85
|
# File 'lib/games_and_rpg_paradise/mud/client/client.rb', line 83
def host_port?
@internal_hash[:host_port]
end
|
#host_uri? ⇒ Boolean
Also known as:
host?, your_host?
#
host_uri?
The remote URL to the host, such as “mud.xyllomer.de”.
#
99
100
101
|
# File 'lib/games_and_rpg_paradise/mud/client/client.rb', line 99
def host_uri?
@internal_hash[:host_uri]
end
|
#login_name? ⇒ Boolean
Also known as:
name?, user_name?, your_login_name?
107
108
109
|
# File 'lib/games_and_rpg_paradise/mud/client/client.rb', line 107
def login_name?
@internal_hash[:login_name]
end
|
#login_password? ⇒ Boolean
Also known as:
password?
90
91
92
|
# File 'lib/games_and_rpg_paradise/mud/client/client.rb', line 90
def login_password?
@internal_hash[:login_password]
end
|
#reset ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# File 'lib/games_and_rpg_paradise/mud/client/client.rb', line 57
def reset
@internal_hash = {}
@internal_hash[:login_name] = 'name_of_the_character_goes_in_here'
@internal_hash[:login_password] = 'xyz'
@internal_hash[:host_port] = 3000
@internal_hash[:host_uri] = 'mud.xyllomer.de'
end
|
#set_login_name(i) ⇒ Object
Also known as:
login_name=, your_login_name=
116
117
118
|
# File 'lib/games_and_rpg_paradise/mud/client/client.rb', line 116
def set_login_name(i)
@internal_hash[:login_name] = i
end
|
#set_login_password(i) ⇒ Object
Also known as:
login_password=
124
125
126
|
# File 'lib/games_and_rpg_paradise/mud/client/client.rb', line 124
def set_login_password(i)
@internal_hash[:login_password] = i
end
|
#telnet_object? ⇒ Boolean
203
204
205
|
# File 'lib/games_and_rpg_paradise/mud/client/client.rb', line 203
def telnet_object?
@telnet_object
end
|