Jump to content

Custom protocol for chat

- - - - -

  • Please log in to reply
3 replies to this topic

#1
mariob316

mariob316

    Newbie

  • Members
  • Pip
  • 8 posts
I'm doing a chat app for school, here are the requirements.

-Server GUI
-Server is able to talk int he chat room
-Server to client private chat
-Server is able to kick and/or ban a user
-Client to client private chat
-File Transfer

Now i know how to do most of this, just gotta still figure out file transfer, but my main question is about making a protocol for sending the messages/kick/ban/private chat

What would be the easiest way for this? Making a class like sendMessage and making it Serializable? or just plain text with using subString method. Either way does anyone have an example of either one to get me started.

Thanks :D

#2
iceman4154

iceman4154

    Newbie

  • Members
  • PipPip
  • 26 posts
There are millions of ways to get this done, some of which are more complicated than others.
If this was my project, I would have my protocol set up as follows.

Example of a packet protocol:
[packet]
A - sizeof(D) - size of message to send
B - command id - represents the type of packet sent (login, private message, ect)
C - destination - destination to where packet is to be sent
D - message text
[/packet]

Something like that would work for the most part, you could also do command parameters like so.

Example of a packet protocol (with command params):
[packet]
A - sizeof(D) - size of message to send
B - command id - represents the type of packet sent (login, private message, ect)
C - destination - destination to where packet is to be sent
D - body
[/packet]

What the body would look like:
[body]
A - Number of parameters
B - sizeof©
C - command parameter
[/body]

Example of a login packet would be:
[packet]
A - sizeof(D) - size of message to send
B - 0x1337
C - [server address]
D - 2, 4, "test", 5, "test1"
[/packet]

I hope this helps, this is just a quick idea of how I would most likely do it. :c-laugh:

#3
mariob316

mariob316

    Newbie

  • Members
  • Pip
  • 8 posts
alright i get it, thanks :c-cool: Im gonna play around with it and see what i can come up with

#4
iceman4154

iceman4154

    Newbie

  • Members
  • PipPip
  • 26 posts
Glad to help. :)




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users