Class: GamesAndRpgParadise::Mud::Client

Inherits:
Base
  • Object
show all
Includes:
FileUtils::Verbose
Defined in:
lib/games_and_rpg_paradise/mud/client/client.rb

Overview

Client

Instance Method Summary collapse

Methods inherited from Base

#find_adverb_for, #lang_wnum, #sentence, #word_wrap

Constructor Details

#initializeClient

#

initialize

#


50
51
52
# File 'lib/games_and_rpg_paradise/mud/client/client.rb', line 50

def initialize
  reset
end

Instance Method Details

#close_the_connectionObject

#

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_loginObject Also known as: do_login

#

do_connect_and_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 
  e
  e 'Trying to Init the telnet-object next ...'
  e
  # ================================================================== #
  # Build up our Telnet object next:
  # ================================================================== #
  @telnet_object = Net::Telnet::new({
    'Host'     => host_uri?,
    'Port'     => host_port?,
    'Password' => password?,
    'Prompt'   => /[$%#>] \z/n,
    'Timeout'  => 30
    #
    #'Telnetmode' => false    
  }) { |return_msg| 
    display_with_token("Return Message: #{return_msg}")
  }
  # Telnet login follows this mode:
  #
  #  login(options, password = nil) {|recvdata| ...}
  #
  display_with_token('Init Object finished.')
  @telnet_object.(@login_name, @login_password)  { |entry|
    print entry
  }
  #do  |return_msg| 
  #   "Doing telnet login"
  #  puts return_msg.class
  #  display_with_token(return_msg)
  #end
  e 'Continuation ...'
  @telnet_object.cmd('look')
  close_the_connection
end

#host_port?Boolean

#

host_port?

#

Returns:

  • (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”.

#

Returns:

  • (Boolean)


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?

#

login_name?

#

Returns:

  • (Boolean)


107
108
109
# File 'lib/games_and_rpg_paradise/mud/client/client.rb', line 107

def 
  @internal_hash[:login_name]
end

#login_password?Boolean Also known as: password?

#

login_password?

#

Returns:

  • (Boolean)


90
91
92
# File 'lib/games_and_rpg_paradise/mud/client/client.rb', line 90

def 
  @internal_hash[:login_password]
end

#resetObject

#

reset (reset tag)

#


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
  # ======================================================================= #
  @internal_hash[:login_name]     = 'name_of_the_character_goes_in_here'
  # ======================================================================= #
  # === :login_password
  # ======================================================================= #
  @internal_hash[:login_password] = 'xyz'
  # ======================================================================= #
  # === :host_port
  # ======================================================================= #
  @internal_hash[:host_port]      = 3000
  # ======================================================================= #
  # === :host_uri
  # ======================================================================= #
  @internal_hash[:host_uri]       = 'mud.xyllomer.de'
end

#set_login_name(i) ⇒ Object Also known as: login_name=, your_login_name=

#

set_login_name

#


116
117
118
# File 'lib/games_and_rpg_paradise/mud/client/client.rb', line 116

def (i)
  @internal_hash[:login_name] = i
end

#set_login_password(i) ⇒ Object Also known as: login_password=

#

set_login_password

#


124
125
126
# File 'lib/games_and_rpg_paradise/mud/client/client.rb', line 124

def (i)
  @internal_hash[:login_password] = i
end

#telnet_object?Boolean

#

telnet_object?

#

Returns:

  • (Boolean)


203
204
205
# File 'lib/games_and_rpg_paradise/mud/client/client.rb', line 203

def telnet_object?
  @telnet_object
end