mirror of
https://github.com/fromchat-messenger/web.git
synced 2026-09-23 03:25:07 +03:00
Add documentation
This commit is contained in:
@@ -1,13 +1,30 @@
|
||||
/**
|
||||
* @fileoverview WebSocket connection management for real-time chat
|
||||
* @description Handles WebSocket connections, message processing, and auto-reconnection
|
||||
* @author Cursor
|
||||
* @version 1.0.0
|
||||
*/
|
||||
|
||||
import { currentUser } from "./auth";
|
||||
import { addMessage } from "./chat";
|
||||
import { API_FULL_BASE_URL } from "./config";
|
||||
import type { WebSocketMessage, Message } from "./types";
|
||||
import { delay } from "./utils";
|
||||
import { delay } from "./utils/utils";
|
||||
|
||||
function create() {
|
||||
/**
|
||||
* Creates a new WebSocket connection to the chat server
|
||||
* @function create
|
||||
* @returns {WebSocket} New WebSocket instance
|
||||
* @private
|
||||
*/
|
||||
function create(): WebSocket {
|
||||
return new WebSocket(`ws://${API_FULL_BASE_URL}/chat/ws`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Global WebSocket instance
|
||||
* @type {WebSocket}
|
||||
*/
|
||||
export let websocket = create();
|
||||
|
||||
// --------------
|
||||
|
||||
Reference in New Issue
Block a user