Git Product home page Git Product logo

cqsocketapi's Introduction

CQSocketAPI

CoolQ Socket API written in VC++.

一个酷Q的 Socket 代理插件

Installation

  1. Place org.dazzyd.cqsocketapi.cpk into CoolQ app folder.
  2. Enable CQSocketAPI in CoolQ APP management window.
  3. Restart CoolQ.

Configuration

Default Config.ini file will generate in org.dazzyd.cqsocketapi folder.

QQBot

You can write your owned bot based on my qqbot in Python 3.

Protocol

Communication

The communication between server and clients is sending UDP frame to each other.

The server listens on port 11235.

Clients should send ClientHello frame to inform server of client port. ClientHello frame must be sent on startup and every (at most) 5 minutes.

A UDP frame contains one Prefix and multiple Fields. Prefix and Fields are joined by one space.

安装

  1. org.dazzyd.cqsocketapi.cpk复制粘贴到酷Q的app文件夹中。
  2. 在酷Q应用管理界面启用对应插件。
  3. 重启酷Q

配置

编辑Config.ini文件可以改变一些设置,文件位于org.dazzyd.cqsocketapi文件夹中。

[Server]
SERVER_PORT=11235           // 监听端口
CLIENT_SIZE=32             // 最大允许客户端数量
CLIENT_TIMEOUT=300           // 客户端超时时间(秒)
FRAME_PREFIX_SIZE=256         // 数据包前缀大小(字节)
FRAME_PAYLOAD_SIZE=32768       // 数据包数据区域大小(字节)

通讯协议

信息交换

插件(服务端)与客户端(您自己实现的,下同)进行UDP数据包交换。

插件默认监听本地11235端口。

客户端需要每隔至少5分钟发送一次ClientHello信息以保持连接。 该信息需包含客户端的端口。

注:所有文本数据需经过GB18030编码的base64转码后进行传送

单个UDP数据包由前缀与多个由空格作为间隔的区域组成。

Server Sent Frame 服务端数据包规格

Frame = Prefix (max 256) + Payload (max 32768)

Prefix = 'ServerHello'
Payload = ClientTimeout + PrefixSize + PlayloadSize + FrameSize

Prefix = 'PrivateMessage'
Payload = QQ + EncodedText

Prefix = 'GroupMessage'
Payload = GroupID + QQ + EncodedText

Prefix = 'DiscussMessage'
Payload = DiscussID + QQ + EncodedText

Prefix = 'GroupMemberDecrease'
Payload = GroupID + QQ + OperatedQQ

Prefix = 'GroupMemberIncrease'
Payload = GroupID + QQ + OperatedQQ

EncodedText = base64_encode( GB18030_encode( text ) )

Client Sent Frame 客户端数据包规格

Frame = Prefix (max 256) + Payload (max 32768)

Prefix = 'ClientHello'
Payload = Port

Prefix = 'PrivateMessage'
Payload = QQ + EncodedText

Prefix = 'GroupMessage'
Payload = GroupID + EncodedText

Prefix = 'DiscussMessage'
Payload = DiscussID + EncodedText

EncodedText = base64_encode( GB18030_encode( text ) )

Example Frame 数据包范例

GroupMessage 123456 10000 dGVzdCCy4srU

cqsocketapi's People

Contributors

artoria2e5 avatar bpazy avatar mrjetchen avatar paspy avatar yukixz avatar

Watchers

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