Impl basic ws binary proto with data and execution state manipulation

This commit is contained in:
2025-10-10 03:19:45 +03:00
parent 2ff6b1a454
commit 165a96aa3c
44 changed files with 2065 additions and 2269 deletions

29
inc/proto/msg.h Normal file
View File

@@ -0,0 +1,29 @@
#ifndef __PROTO_MSG_H__
#define __PROTO_MSG_H__
#include "wsServer/include/ws.h"
#include <stdlib.h>
#include "client.h"
typedef struct {
ClientContext* client;
uint8_t* msg;
size_t msgLen;
} OutgoingMessage;
typedef struct {
uint64_t nonce;
uint8_t packetType;
uint8_t payloadHeader;
const void* payload;
size_t payloadLen;
} BaseMessage;
BaseMessage* parseMessage(const uint8_t* bytes, size_t size);
void fillHead(uint64_t nonce, uint8_t packetType, uint8_t payloadHeader, uint8_t* outmsg);
uint8_t* createControlNotifyMessage(uint64_t nonce, uint64_t clockCounter, uint8_t newEmulState, size_t* lenOut);
uint8_t* createDoneRegMessage(uint64_t nonce, uint8_t X, uint64_t devId, uint64_t segId, uint64_t startAddr, uint64_t segLength, uint32_t regId, size_t* lenOut);
uint8_t* createStreamSegmentPush(uint8_t mode, uint32_t regId, uint64_t clockCounter, uint8_t* payload, size_t payloadLen, size_t* lenOut);
uint8_t* createClientSetup(uint64_t nonce, ClientContext* ctx, size_t* lenOut);
#endif //ifndef __PROTO_MSG_H__