Jump to content

Question about Chatprogramming

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
5 replies to this topic

#1
MaZy

MaZy

    Newbie

  • Members
  • Pip
  • 4 posts
Hello,

i am working most time with AutoIt. Its easy to make little things. My newest project is to make a chat + server(to chat with my friends if we are in school and get bored to write so much in words or excel :S). To make a server is easy. I got commands like /me or /say(default message).

Server gets first the message from client like "/me Username is lazy". Server is looking for slash "/" and then looking for what is there written. It looks for "space"("/me ") and then it knows the word has ended. It cuts out from others to var. Next one is "Username is lazy". Same again with cut to 2 var "message" and "Username".

After ideas like an onlinelist(who is online=) or pms was not easy to edit everything on serverside. I am decided to make something like codes in clients. Like client is checking: "code1234" = Message, "code1235" = somebody has joined to the server.

So, my question is. How is the real chats working if there many difference commands like /nick to change nick or online lists. Is it working with pakets? Or is this easier on c++. In java i think there are many difference. Cause client is most time connecting with his browser.

If i am thinking about mIrc and the server..i can't explain me how it is working. It must be everything serverside. Client should have no packets or codes. Caus u can connect to ircserver with autoit too. But then how can u get onlinelist working. Or is the reference to look for pakets? lol.

Anyway. i need rlly on the part ur help. Can't continue before or i do wrong and have later toooo hard

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
One of the keys to any chat system is having a well-defined protocol. You have to decide what the system is supposed to do before you try to code against it. For example, IRC's protocol can be found here: RFC 1459

Once you have the protocol designed, you can decide whether you are dealing with a client-server or peer-to-peer structure. For example, with IRC you need an IRC daemon to act as the server, and an IRC client for the client.

Note, all communication takes the form of packets, at the lowest level. If you are thinking in terms of packets, however, you are thinking way too low-level. Think in terms of messages. The client sends a message to the server, the server responds with another message. The server will send messages based on your status and the actions of others.

None of this is simple, there are a LOT of details to it.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
MaZy

MaZy

    Newbie

  • Members
  • Pip
  • 4 posts
thx for the good information. I've understand a little bit. But the messages.. is that not manipulateable???

#4
Orjan

Orjan

    Writes binary right handed and hex left handed

  • Moderators
  • 3,298 posts
What WP means, is that you send the info via the computer's own network system, and let the network system handle the packages and stuff, you just read and send info through the network api.
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall

#5
MaZy

MaZy

    Newbie

  • Members
  • Pip
  • 4 posts
K, again for me to understand completly.
An Example:
Client 1,
Client 2,
Server,

User writes to channel "/me sayss hello". How i've understood should client sent something like "USERACTION says hello" to server and server gets something like "USERACTION says hello"^^ or just like my version "/me says hello". Server sending this now to all connected clients. Client 2 in channel gets from Server "USERACTION says hello". Client checks what USERACTION means. Then he writes in in italic style "Client 1 says hello".

Right?

This is very long way for this little chat when i am thinking about onlinelist lol.

hm i believe i will make simple chat for only to connect to ircserver. So i can train my knowlegde and basics about programming chat.

btw: Sorry of my bad written lines if you found wrong written words. My english is not so good.

#6
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Rule #1 in programming: keep it simple.

That said, have client 1 just send the raw message to the server. It should probably be a pair of values, like "USER","MESSAGE". The server that looks at the message to see if it is a message the server needs to process (such as "/nick WingedPanther"). If not, it simply rebroadcasts the pair of values to the clients that can here, perhaps as the value pair "NICK","MESSAGE".

Let the clients be responsible for the parsing/display. The server has a LOT of work to do, don't make it work any harder than necessary.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog