[Tutor] Asyncore Problem
Kuros
kuros@sbcglobal.net
Wed Apr 30 06:24:05 2003
This is a multi-part message in MIME format.
------=_NextPart_000_0091_01C30ED8.A18CF440
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Oh, ignore the "data =3D None" part in my snippet. That was one way I =
was trying to fix it. it didn't work. =3DP
----- Original Message -----=20
From: Kuros=20
To: tutor@python.org=20
Sent: Wednesday, April 30, 2003 5:14 AM
Subject: [Tutor] Asyncore Problem
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_0091_01C30ED8.A18CF440
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>Oh, ignore the "data =3D None" part in =
my snippet.=20
That was one way I was trying to fix it. it didn't work. =
=3DP</FONT></DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style=3D"FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV=20
style=3D"BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: =
black"><B>From:</B>=20
<A title=3Dkuros@sbcglobal.net =
href=3D"mailto:kuros@sbcglobal.net">Kuros</A>=20
</DIV>
<DIV style=3D"FONT: 10pt arial"><B>To:</B> <A title=3Dtutor@python.org =
href=3D"mailto:tutor@python.org">tutor@python.org</A> </DIV>
<DIV style=3D"FONT: 10pt arial"><B>Sent:</B> Wednesday, April 30, 2003 =
5:14=20
AM</DIV>
<DIV style=3D"FONT: 10pt arial"><B>Subject:</B> [Tutor] Asyncore =
Problem</DIV>
<DIV><BR></DIV>
<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=20
am 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".=20
If its not, it sends data (the input from the socket) to process =
input, where=20
I 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=20
=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.=20
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Now, each of those functions (gName, =
etc) work=20
ok, except for this. I want to get new input for each function, but it =
is=20
passing the first input to every one of those. So when ased for a =
name, it=20
passes what they typed in to every one of those functions, without =
getting new=20
input for 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></BLOCKQUOTE></BODY></HTML>
------=_NextPart_000_0091_01C30ED8.A18CF440--