Products Technologies Demo Docs Blog Support Company

Creating a WebSocket Server Project with Node.js

The @txtextcontrol/tx-websocket-server npm package enables Node.js to host the backend for TX Text Control document editors. This tutorial covers installing Express and the package, creating the app.js entry point with server configuration, and connecting it to an Angular editor.

Creating a WebSocket Server Project with Node.js

This tutorial uses Visual Studio Code that can be downloaded for free.

Creating the WebSocket Server Project

  1. Open a Node.js command prompt, create an empty folder called "websocket-server", navigate into and type in the following command to install Express, the minimalist web framework for node:

    npm i express
  2. Now, install the WebSocket Server package of TX Text Control:

    npm i @txtextcontrol/tx-websocket-server
  3. Open this folder in Visual Studio Code by typing in the following command:

    code .
  4. In Visual Studio Code, create a new file named app.js in the project's root folder:

    Copy the following code into this JavaScript file and save it:

    const { WebSocketServer } = require('@txtextcontrol/tx-websocket-server');
    const express = require('express');
    const app = express();
    const server = app.listen(8080);
    
    var wsServer = new WebSocketServer(server);
  5. Back in the command prompt, start the Node.js application by typing in the following command:

    node app.js

Connecting the Angular Application

When connecting an Angular based document editor application with this Node.js WebSocket Server, add this endpoint to the webSocketURL parameter:

<tx-document-editor
  width="1000px"
  height="500px"
  webSocketURL="ws://localhost:8080/TXWebSocket">
</tx-document-editor>

Stay in the loop!

Subscribe to the newsletter to receive the latest updates.

Angular

Integrate document processing, editing, sharing, collaboration, creation, electronic signatures, and PDF generation into your Angular Web applications.

Learn more about Angular

Related Posts

AngularDocument EditorNode.js

Creating an Angular Document Editor Application with a Node.js WebSocket Server

This tutorial shows how to create an Angular application that uses the Document Editor with a Node.js WebSocket server.


AngularASP.NETTutorial

Integrate Document Editing into any HTML Client using the HTML Widget

The TX Text Control JavaScript widget enables document editing in any HTML page without ASP.NET. Integration requires a script tag in the HEAD, a container DIV, and a widget constructor call with…


AngularASP.NETTutorial

Creating an Angular Document Editor Application

The @txtextcontrol/tx-ng-document-editor package integrates the TX Text Control HTML5 editor into Angular via Angular CLI. A WebSocket server handles WYSIWYG synchronization. This tutorial covers…


AngularASP.NETReporting

Text Control Roadmap 2019: High DPI Support, Forms, Node.js and Angular

The 2019 Text Control roadmap covers high DPI support for 4K+ screens with 900+ vector icons, UI Automation for Windows Forms, MS Word compatible form creation with deployment workflows, and a…


AngularASP.NETBlazor

Building an ASP.NET Core Backend (Linux and Windows) for the Document Editor…

This article shows how to create a backend for the Document Editor and Viewer using ASP.NET Core. The backend can be hosted on Windows and Linux and can be used in Blazor, Angular, JavaScript, and…

Share on this blog post on: