[Tutor] Asyncore Problem
Kuros
kuros@sbcglobal.net
Wed Apr 30 06:15:02 2003
This is a multi-part message in MIME format.
------=_NextPart_000_0055_01C30ED7.5664CCF0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hiya,
I am using asyncore to build a MUD-like game. I am having one problem =
though.
I have \n set as the terminator. In the def found_terminator function, I =
have it set to do this..
check to see if the socket's state is "logedIn". If its not, it sends =
data (the input from the socket) to process input, where I have this...
def processLogin(ch, data):
if ch.state =3D=3D dConst.getName:
gName(ch, data)
data =3D None
if ch.state =3D=3D dConst.getNewName:
write_to_self(ch, 'Please choose a name: ')
gNewName(ch, data)
if ch.state =3D=3D dConst.getPassword:
write_to_self(ch, 'Enter your password: ')
gPassword(ch, data)
if ch.state =3D=3D dConst.getNewPassword:
write_to_self(ch, 'Choose a password: ')
gNewPassword(ch, data)
ch is the socket, data is the input.=20
Now, each of those functions (gName, etc) work ok, except for this. I =
want to get new input for each function, but it is passing the first =
input to every one of those. So when ased for a name, it passes what =
they typed in to every one of those functions, without getting new input =
for each function.
Anyone have a solution for this?
Thanks,
Kuros
------=_NextPart_000_0055_01C30ED7.5664CCF0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2722.900" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hiya,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>I am using asyncore to build a MUD-like =
game. I am=20
having one problem though.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>I have \n set as the terminator. In the =
def=20
found_terminator function, I have it set to do this..</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>check to see if the socket's state is =
"logedIn". If=20
its not, it sends data (the input from the socket) to process input, =
where I=20
have this...</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>def processLogin(ch,=20
data):<BR> if ch.state =3D=3D=20
dConst.getName:<BR> =
=20
gName(ch, =
data)<BR> data =3D =
None<BR> if ch.state =3D=3D=20
dConst.getNewName:<BR> &nb=
sp;=20
write_to_self(ch, 'Please choose a name:=20
')<BR> =
gNewName(ch,=20
data)<BR> if ch.state =3D=3D=20
dConst.getPassword:<BR> write_to_self(ch, 'Enter your =
password:=20
')<BR> =
gPassword(ch,=20
data)<BR> if ch.state =3D=3D=20
dConst.getNewPassword:<BR>  =
; =20
write_to_self(ch, 'Choose a password:=20
')<BR> =
gNewPassword(ch,=20
data)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>ch is the socket, data is the input. =
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Now, each of those functions (gName, =
etc) work ok,=20
except for this. I want to get new input for each function, but it is =
passing=20
the first input to every one of those. So when ased for a name, it =
passes what=20
they typed in to every one of those functions, without getting new input =
for=20
each function.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Anyone have a solution for =
this?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Thanks,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Kuros</FONT></DIV></BODY></HTML>
------=_NextPart_000_0055_01C30ED7.5664CCF0--