Private Chat Protocol

Secure, Reliable, Real-time Communication

v1.2.0

About Private Chat Protocol

Private Chat Protocol is a WebSocket-based communication system designed for secure and efficient real-time messaging. The protocol supports various message types, room-based communication, and user authentication mechanisms.

Key Features

Message Types

JOIN_ROOM

Sent when a user wants to join a specific chat room

LEAVE_ROOM

Sent when a user exits a chat room

CHAT_MESSAGE

Standard text message shared in a room

IMAGE_MESSAGE

Message containing image data (base64 encoded)

USER_LIST

System message containing the list of users in a room

ERROR

System-generated error messages

Connection Example

// Connect to WebSocket server
const ws = new WebSocket('ws://your-server/ws');

// Join a room
ws.send(JSON.stringify({
  type: 'JOIN_ROOM',
  roomId: 'room-123',
  username: 'user123',
  timestamp: Date.now()
}));

// Send a message
ws.send(JSON.stringify({
  type: 'CHAT_MESSAGE',
  roomId: 'room-123',
  username: 'user123',
  content: 'Hello world!',
  timestamp: Date.now()
}));