Giter VIP home page Giter VIP logo

qt5_p2p_chatclient-kssa's Introduction

Qt5_P2P_ChatClient-KSSA

中文介绍

A P2P chat application client for local area network (Windows) developed using Qt5 and C++.

Use technology:

  1. Qt5/C++ development

  2. Qtcreator/Qtquick design UI

3.Qml+Qss beautify the interface

  1. Customize Qtsocket list (array container) to maintain multi-party P2P connection

  2. Rewrite the mouse click event to realize the small right-click menu of the friend list

  3. Use Qtquick to maintain a message panel list for each friend who is chatting

  4. Use MapSignal to pass custom parameters to the SLOT function of connect to switch the corresponding Socket

Realization function:

  1. Add/remove friends

  2. Personal/friend business card (avatar, nickname, profile)

  3. Send a heartbeat packet to the intermediate server to maintain the state

  4. Multi-branch P2P chat

  5. File transfer (confirmation mechanism) (larger files can be transferred)

  6. One-to-one chat message panel

Project highlights

1.QVector <QTcpSocket*> ListTcpsocket maintains a list of sockets
2. QSignalMapper does the mapping of binding events (solves the problem that SLOT cannot pass parameters)
    ServerMapper->setMapping(LinkInfo.ListTcpsocket.last(),LinkInfo.ListTcpsocket.count());
    connect(LinkInfo.ListTcpsocket.last(), SIGNAL(readyRead()), ServerMapper, SLOT(map()));
    connect(ServerMapper, SIGNAL(mapped(int)), this, SLOT(changeTempTcpsocket(int)));
3. QBuffer unified data transmission method, easy to read and write:
    QByteArray data;
    data.resize(sizeof(LoginMessage));
    QBuffer buffer(&data);
    buffer.open(QIODevice::WriteOnly);
    QDataStream out(&buffer);
    LoginMessage Message;
    Message.type=UsrLogin;
    qDebug()<<user_id <<user_password<<endl;
    Message.userid=user_id;
    Message.password=user_password;
    Message.Message="I want to login in,please.";
    out<<Message.type<<Message.userid<<Message.password<<Message.Message<<true;
	buffer.close();
    QByteArray data = this->tcpSocket->readAll();
    QBuffer buf(&data);
    buf.open(QIODevice::ReadOnly);
    QDataStream in(&buf);
4. Client socket explanation: tcpSocket is used to connect to the server; tempP2P is a socket that dynamically receives background messages; nowP2P sockets handle requests from friends; actP2P actively sends requests
5. The process of sending and receiving files: the emitFile type message sends and receives the detailed information of the file. After the other party receives it, it creates the corresponding file and opens the progress bar panel; File type messages are used to send or receive file content and update the progress bar; accessFile type messages Responsible for sending or receiving confirmation, indicating that the reception of this group of data is complete and waiting for the next group of data.

ScreenShots

KSSA_Login

KSSA_ChatExample

qt5_p2p_chatclient-kssa's People

Contributors

sovea avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.