Chocal Chat is a cross platform application that can run in a local network.
This repository contains the server application that is needed to handle clients.
-
Chocal Chat server application is based on Qt Quick, so you need to install Qt development tools. Currently I am working with Qt 5.6.0.
-
It is tested on Fedora 23 and Windows 10, but not on Mac. Although it should be run there without any problems.
-
Clone repository from github and open
ChocalServer.pro
in Qt Creator. -
Use
lrelease
to generate translationqm
files. For example if Qt bin directory is in your PATH environment variable you can runlrelease-qt5 ChocalServer.pro
or if it is not you can runpath/to/qt/bin/lrelease ChocalServer.pro
or in a Windows environmet runC:\Qt\Qt5.6.0\5.6\msvc2015_64\bin\lrelease.exe ChocalServer.pro
. Note that becauseqm
files are supposed to be bundled in a.qrc
file, so you SHOULD do this step, otherwise the build operation will fail.
{
user_key: "",
type: "",
message: "",
image: "",
image_type: "" // If image is presented
}
type
should be one of plain
, image
or register
.
message
is the message that user wants to send to others.
image
is base64 encoded string of the image that user wants to send. This should have a value when using type
of image
, but in other cases it can be empty. Note that when type
is image
, there should be an image_type
field which includes MIME type of image.
user_key
is validation key of client to connect to server. This key will generate once user is first connected to server and will return back to client. In next messages client should provide this key.
{
type: "",
name: "",
message: "",
image: "",
image_type: "" // If image is presented
}
type
will be one of plain
, image
, info
, update
, accepted
or error
.
name
is sender client name.
message
is the message that user wants to send to others.
image
is base64 encoded string of the image that user wants to send. This will have a value when using type
of image
, but in other cases it will be empty. Note that when type
is image
, there should be an image_type
field which includes MIME type of image.
Chocal Server will send these type of message to clients.
accepted
: Means client is successfuly connected to server and now can send messages. When type isaccepted
Chocal Server will also another filed namedonline_users
which includes name and image of all current online users.plain
: Means normal text message.image
: Means an image message.info
: Means an informative message that is not actually sent by a client and it is generated by server.update
: Means some change has ocurred.error
: Means something went wrong and server is sent error details to client or clients.
On the other hand Chocal Server will expect these type of messages to recieve:
register
: Means that client wants to connect to chat.plain
: Means normal text message.image
: Means an image message.
Clients can connect to server by sending below message to server:
{
type: "register",
name: "",
image: "", // Optional
image_type: "" // Required when image is presented
}
If the name
is taken currently the server will return an error message, otherwise it will be return a message of type accepted
to client with a user_key
property like this:
{
type: "accepted",
name: "",
message: "",
user_key: "",
online_users: [
{
name: "",
image: "",
image_type""
},
...
]
}
At this point, client is connected to server successfuly and now is able to send messages using its user_key
. Note that currently online clients are passed in online_users
field which is an array of objects that have name
, image
and image_type
fields.
When a new change is made, Chocal Server will send an update
message to all clients. These updates are following below structure:
{
type: "update",
update: "",
name: "",
...
}
In the update
field we have one of userJoined
or userLeft
values.
- If it is
userJoined
means a new user is joined to chat and his Avatar picture will be in theimage
field in base64 encode and MIME type of avatar will be inimage_type
field. - If it has value of
userLeft
it means a user had left the chat and we can find his name inname
field.
Chocal Chat has several type of clients. Below you can see a list of these clients:
- Chocal Chat Web Client : https://github.com/J-TAG/chocal-chat-web
- Chocal Chat Android Client : https://github.com/J-TAG/chocal-chat-android
- Chocal Chat Desktop(Linux, Mac and Windows) Client : https://github.com/J-TAG/chocal-chat-desktop