Files

66 lines
3.0 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
// +----------------------------------------------------------------------
// | YwxApp [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2026-2036 http://ywxapp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: ywxapp<admin@ywxapp.cn>
// +----------------------------------------------------------------------
declare (strict_types = 1);
namespace addon\wxchat\worker\enum;
// ==================== 第一层:协议帧类型(传输层) ====================
enum MsgFrame: string {
/**
* 聊天内容 文本 图片 视频 语音 文件
*/
case PING = 'ping'; // 心跳帧(客户端定时发送,服务端回复PONG)
case PONG = 'pong';
/**
* 聊天内容 文本 图片 视频 语音 文件
*/
case CHAT = 'chat';
/**
* 系统消息 心跳 认证 错误
*/
case SYSTEM = 'sys';
/**
* 关系消息 加好友 同意加好友 拒绝加好友 加群组 同意加入 拒绝加入
*/
case RELATION = 'rel';
/**
* 状态消息 正在输入 送达 未读 已读 撤回
*/
case STATUS = 'state'; // 连接控制(心跳/认证/状态)
case ERROR = 'err'; // 协议错误(独立错误帧)
}
// [
// 'id' => 'msg_1234567890abcdef', // 唯一IDUUID / 雪花ID,服务端可生成)
// 'from' => 'user_001', // 消息发送者 UID
// 'to' => 'user_002', // 接收者 UID(单聊) 或 to_gid: "group_001"(群聊)
// 'totype' => 'member', // 接收目标类型:user(私聊) / group(群聊)
// 'type' => 'text', // 消息类型:text / image / voice / video / file / system / notification / typing / read / revoke
// 'action' => 'chat.send', // 【可选】业务动作,用于服务端路由(如 chat.send, system.notify, typing.start
// 'content' => 'Hello world!', // 消息正文内容(文本消息直接是字符串,其他类型可能是 URL 或结构化数据)
// 'extra' => [ // 【可选】扩展字段,根据 type 不同而不同
// 'image_url' => 'https://xxx.com/img.jpg',
// 'image_width' => 800,
// 'image_height' => 600,
// 'voice_url' => 'https://xxx.com/voice.amr',
// 'voice_duration' => 3,
// 'file_name' => 'doc.pdf',
// 'file_size' => 102400,
// 'reply_to_msg_id' => 'msg_0987654321', // 引用回复的消息ID
// 'mention_uids' => ['user_003', 'user_004'] // @了哪些人
// ],
// 'timestamp' => 1700000000123, // 消息发送时间(毫秒级 UNIX 时间戳,推荐)
// 'status' => 'sent', // 消息状态:sending / sent / delivered / read / failed
// 'encipher' => true, // 是否经过 AES 加密(可选字段,用于标识)
// 'revoked' => false // 是否被撤回
// ];