/chatnacional.net

A chat server based on regional public chat rooms.

Primary LanguageC#

canalnacional .NET

A channel server based on national public channel.

This is an educative example for basic C#/.NET.

Requirements

  • .NET Core 3.1

The protocol : SNCP - A general description

The Simple National Channel Protocol defines the communication protocol between clients and this server. Server will listen for clients using port TCP number 12345 (by default). All the communication will be assumed to use UTF-8 encoding.

Identification

Clients will establish connection and receive a simple welcome message from the server, then the client will send the LOGIN command to identify himself, the server will respond accordingly with SUCCESS or ERROR.

Initial channel

After successful identification, clients will be assigned in the default(national) channel, and will start to receive any message sent un that channel from that moment, those messages will be preceded by RECEIVE commands send by the server.

To send messages to the channel the client will use the SEND command and the desired message. Any UTF-8 string with no more than 1024 characters will be valid.

To disconnect from the server, client will will send the LOGOUT command.

Any command issue by the client will be answered by the server using SUCCESS or ERROR commands.

Specific Channel

Clients can communicate in more specific channels, to do that, they should use the CONNECT command followed by the specific room name. Room names can be any string composed by any non white character, with a max lengh of 64 characters.

Clients will start receiving message from the connected channels, those message will be sent by the server preceded by the RECEIVE command and the channel name.

To send a message for a specify channel, SEND command will be used with the channel name and a message with no more than 1024 characters.

To disconnect from a channel the client will sent DISCONNECT and the channel name. Using DISCONNECT and the default channel will disconnect the client from the server, the same as using LOGOUT

Any command issue by the client will be answered by the server using SUCCESS or ERROR commands.

Server events

In any moment server can notify from events to the client, those events will be simple string messages preceded by the STATUS command. the message will have no more than 1024 UTF-8 characters.

Errors

In case of errors server will sent and ERROR command with the details of the error.