The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> Python Programming
|
Chat Server Version 0.1
Discuss Chat Server Version 0.1 in the Python Programming forum on Dev Shed. Chat Server Version 0.1 Python Programming forum discussing coding techniques, tips and tricks, and Zope related information. Python was designed from the ground up to be a completely object-oriented programming language.
|
|
 |
|
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

March 13th, 2004, 01:56 PM
|
|
Registered User
|
|
Join Date: Aug 2003
Posts: 217
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Chat Server Version 0.1
As you may or may not know, I've been writing a small chat server and chat client. It's not done yet (my todo list is in the file  ) but I wanted to post it here for any suggestions. I would appreciate any help on how to make the code 'better'. Thanks in advance.
Btw, I havn't included the client as it is just used for debugging atm.
|

March 13th, 2004, 02:22 PM
|
 |
Hello World :)
|
|
Join Date: Mar 2003
Location: Hull, UK
|
|
Impresive, clean and highly OOP! Looking very good so far  . Will have a sit down and read though it a little latter. I'll let you know more then  .
Mark.
__________________
programming language development: www.netytan.com – Hula
|

March 13th, 2004, 02:32 PM
|
 |
Mini me.
|
|
Join Date: Nov 2003
Location: Cambridge, UK
|
|
This is looking good!
Two thumbs from me:
Any chance to get to client code? I'd like to test your server
Grim
|

March 13th, 2004, 03:02 PM
|
|
Registered User
|
|
Join Date: Aug 2003
Posts: 217
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
Thanks for the kind words  . As for the client, I've attached it here. Hopefuly you can figure it out as it's kind of a mess and uncommented. Sorry I can't say much more now because I'm just heading out!
Btw, my friend is writing a GUI client in Perl and should be done soon.
|

March 13th, 2004, 03:40 PM
|
 |
Hello World :)
|
|
Join Date: Mar 2003
Location: Hull, UK
|
|
There was a little problem with your client - port isn't defined. Just check em on this one, the port number should be 50007 right?
Why perl; surly a Python GUI client would be better since the server is Python?
Edit: My bad. The port number should have been supplied though sys.argv... i'm on windows so i just double clicked  .
Mark.
Last edited by netytan : March 13th, 2004 at 03:44 PM.
|

March 13th, 2004, 04:23 PM
|
 |
Hello World :)
|
|
Join Date: Mar 2003
Location: Hull, UK
|
|
|
A little lost, i started the server and two clients (both would have the same IP, not sure if that makes a differance but it might explain some things) but i cant get either to echo in the server window or the other client window.
Maybe you could talk us though a simple server-client test?
Mark.
|

March 13th, 2004, 05:36 PM
|
|
Registered User
|
|
Join Date: Aug 2003
Posts: 217
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Hi, I'm at a friends so I'll need to make this quick. You need to specify a port and a nickname at the command line and optionaly an address.
I probably should have documented it a bit better before posting, sorry. But here is a quick tutorial:
From the client:
say <message> to send a global message (like on irc)
pm <name> <message> to send a private message
pmlist to view all your private messages
messages to view normaly messages (from "say")
From the server:
global <message> to send a global message.
dump to view a raw dump of everything sent out
Uhh I can't think of much more atm, but I'll post again tomarrow. I hope this helps for now.
|

March 14th, 2004, 04:47 AM
|
 |
Only the strong survives!!.
|
|
Join Date: Feb 2003
Location: A World of wonders.
|
|
Im doing the same thing.. except that i will have client & server in one 
|

March 14th, 2004, 09:32 AM
|
|
Registered User
|
|
Join Date: Aug 2003
Posts: 217
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
That client at the moment isn't really usable for a conversation as you need to type a command to send a message and a command to view your messages. I'll post the Perl client and the new server when they're done. The Perl client will look somewhat like mIRC. We're trying to mimic something like IRC rather than MSN, AIM or Yahoo IM.
Btw, the reason for no Python GUI client is that I havn't found many tutorials for wxPython.
Last edited by XxChris : March 14th, 2004 at 09:35 AM.
|

March 14th, 2004, 11:07 AM
|
 |
Mini me.
|
|
Join Date: Nov 2003
Location: Cambridge, UK
|
|
I keep mentioning Boa,  but it does have a tutorial that shows the basics of wxPython from a Boa perspective.
Grim 
|

March 14th, 2004, 11:55 AM
|
|
Registered User
|
|
Join Date: Aug 2003
Posts: 217
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
I'll look into it, thanks  . Btw, has anyone had any troubles with the server or client? Is it working properly?
Last edited by XxChris : March 14th, 2004 at 12:20 PM.
|

March 14th, 2004, 01:29 PM
|
 |
Hello World :)
|
|
Join Date: Mar 2003
Location: Hull, UK
|
|
If by trouble you mean failure to get it working then you can count me in  . For some reason couldn't get the clients to talk with each other, possibly because both the IP addresses are the same but...
Mark.
|

March 14th, 2004, 01:51 PM
|
|
Registered User
|
|
Join Date: Aug 2003
Posts: 217
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
@netytan:
The IP addresses won't affect it as the server uses threads and sockets to differenciate between clients. Here is a little tutorial:
Start the server up:
Code:
./chatserver.py 1024
Start two clients up:
Code:
./chatclient.py 1024 Chris
./chatclient.py 1024 Mark
Now, using the server console you should be able to type "users" and see both of those clients:
Code:
[Aurora:python/projects/chat] chris% ./chatserver.py 50007
> users
127.0.0.1 Mark
127.0.0.1 Chris
You can use the "online" command from either client to get the same effect. Now, since it's just a simple text based client (for debugging) you need to use a command to send a message, and another to view messages. Using "say <message>" from either client will send a message. Use "messages" on the opposite client to view it:
Code:
[Aurora:python/projects/chat] chris% ./chatclient.py 50007 Chris
> say Hi, Mark
Code:
[Aurora:python/projects/chat] chris% ./chatclient.py 50007 Mark
> messages
Chris: Hi, Mark
With the "name <newname>" command you can change your name to whatever you like, as long as it isn't used already. You can use the "events" command from the server console to view things like name changes, disconnections or connections.
Code:
[Aurora:python/projects/chat] chris% ./chatclient.py 50007 Chris
> say Hi, Mark
> name christofer
> say I changed my name!
Code:
[Aurora:python/projects/chat] chris% ./chatserver.py 50007
> users
127.0.0.1 Mark
127.0.0.1 Chris
> events
127.0.0.1 Mark Connected
127.0.0.1 Chris Connected
127.0.0.1 Chris Name: christofer
Code:
[Aurora:python/projects/chat] chris% ./chatclient.py 50007 Mark
> messages
Chris: Hi, Mark
> online
Mark
christofer
> messages
Chris: Hi, Mark
christofer: I changed my name!
There is other stuff like private messages ("pm <user> <message>" and "pmlist" to view your PMs), also you can use "dump" from the server console to view everything it has sent out.
Code:
[Aurora:python/projects/chat] chris% ./chatclient.py 50007 Mark
> pm christofer Your confusing me!
Code:
[Aurora:python/projects/chat] chris% ./chatclient.py 50007 Chris
> pmlist
Mark: Your confusing me!
> messages
Chris: Hi, Mark
christofer: I changed my name!
File sending is comming soon  . Oh, and "quit" quits the server. The clients don't have any clean way to quit atm (It's not really meant to be used  ). I hope this helps!
Last edited by XxChris : March 14th, 2004 at 02:06 PM.
|

March 14th, 2004, 02:07 PM
|
|
Registered User
|
|
Join Date: Aug 2003
Posts: 217
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|

March 14th, 2004, 03:26 PM
|
 |
Hello World :)
|
|
Join Date: Mar 2003
Location: Hull, UK
|
|
Ok, after a failed attempt or two i have it passing messanges quite although my results differ slightly from yours i.e. USERLIST: likes to be printed along with certain commands...
Code:
C:\Documents and Settings\Mark>desktop\chatclient.py 50007 mark
> online
markUSERLIST:
dcUSERLIST:
> messages
dcUSERLIST: :hey
> say hey
>
what ya think? a little bug?
Mark.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|