-
Notifications
You must be signed in to change notification settings - Fork 1
Custom Server
Note: This is incomplete and missing things which are important, for instance: The header which indicates how long of a message (in bytes) that you should be looking for. Reading over the examples will help you in figuring this out.
Want to make a custom server? Perfect! Let's get started.
Your server will need to be made in a language which supports TCP communication. Once you have selected a language, we can begin.
Your server can have custom functionality, including everything from storing chat history to replay to clients when they join, creating commands, user authentication, and more! You could even go so far to integrate your server with Discord to make a connection between Discord and your ICC server. The possibilities are endless.
What exactly does a server have to do in order to be supported by a client? Let's go through the steps that your server will need to go through to connect clients properly.
-
Password Protection - When a client connects to your server, you will need to tell the client if your server is password protected or not. To tell a client what your server is operating in, you will need to send a response with one of two responses. If your server is password protected, send "passwordProtected", otherwise you will send "" (Empty).
-
Password Validation - If your server is password protected, you will need to make sure to check the password they provide. The message you receive next from the client will be the password they provided. If the password is valid, you will need to send "V", otherwise you will need to send the user some sort of message telling them that the password was rejected.
-
Nickname Request - After the client has made it passed password validation, you will need to prompt the user to send a nickname. This message can contain whatever you want, like rules and restrictions.
-
Nickname Response - After the client has decided on a nickname, they will send it to the server. This nickname should be checked, and be regulated. A good recommendation is to prevent duplicates and have a minimum of 4 characters, and a max of 16. If the nickname does not pass your checks, you need to send the user an error message. If it does pass all your checks, you can send them a welcome message before sending them "V". The reason why you should send a welcome message before sending "V" is that the client will change states after receiving "V", which will cause some clients to not display the correct hint for the message.
-
Normal Function - After the client has been sent "V", you may begin sending messages and sending the clients messages. Any further message is not going to use 1-4, this state should be treated as purely user messages.
When the connection is in normal function mode, you can go ahead and do things like run user messages as commands. For instance: You could add the ability for someone to change their nickname with "/nick A New Nick" and do the same things you would do when responding to a nickname request, minus sending "V" as you will not need to update the client state.
That is it! You only need to implement that functionality to create your very own custom server! In the future, your server should support RSA and AES encryption in order to make communication more secure.
As a server maintainer, you should make sure that your server supports the newest features. Check back here often to make sure your implementing everything that is required for smooth operation.