A channel server based on national public channel.
This is an educative example for basic C#/.NET.
- .NET Core 3.1
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.
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
.
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.
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.
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.
In case of errors server will sent and ERROR
command with the details of the error.