Chocal Chat is a cross platform chat application that can run in a local network.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
img
raw
resources/Chocal Logo
translations
.gitignore
About.qml
ChocalServer.pro
FileIO.cpp
FileIO.hpp
Header.qml
LICENSE
MessageDelegate.qml
README.md
Server.qml
Settings.cpp
Settings.hpp
Settings.qml
Splash.qml
Toolbar.qml
UserDelegate.qml
chocal.ico
deployment.pri
main.cpp
main.qml
qml.qrc

README.md

Chocal Chat Server

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 Server

Install

  1. 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.

  2. It is tested on Fedora 23 and Windows 10, but not on Mac. Although it should be run there without any problems.

  3. Clone repository from github and open ChocalServer.pro in Qt Creator.

  4. Use lrelease to generate translation qm files. For example if Qt bin directory is in your PATH environment variable you can run lrelease-qt5 ChocalServer.pro or if it is not you can run path/to/qt/bin/lrelease ChocalServer.pro or in a Windows environmet run C:\Qt\Qt5.6.0\5.6\msvc2015_64\bin\lrelease.exe ChocalServer.pro. Note that because qm files are supposed to be bundled in a .qrc file, so you SHOULD do this step, otherwise the build operation will fail.

Standards

General Type Of A Message That Should Be Sent To Server:

{
    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.

General Type Of A Message That Server Will Send To Clients:

{
    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.

Message Types:

Chocal Server will send these type of message to clients.

  1. accepted : Means client is successfuly connected to server and now can send messages. When type is accepted Chocal Server will also another filed named online_users which includes name and image of all current online users.
  2. plain : Means normal text message.
  3. image : Means an image message.
  4. info : Means an informative message that is not actually sent by a client and it is generated by server.
  5. update : Means some change has ocurred.
  6. 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:

  1. register : Means that client wants to connect to chat.
  2. plain : Means normal text message.
  3. image : Means an image message.

How To Connect To Server:

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.

How To Handle Updates?

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 the image field in base64 encode and MIME type of avatar will be in image_type field.
  • If it has value of userLeft it means a user had left the chat and we can find his name in name field.

Clients

Chocal Chat has several type of clients. Below you can see a list of these clients: