Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using node-ncurses client-side through server-side script?

I wrote a small node.js netServer chat application. I want to work on creating an ncurses user-interface for it. Problem is, the chat application is written server-side, and people connect via netcat, so the question is how I would go about manipulating ncurses on the client-side through it?

like image 905
Reznor Avatar asked Mar 08 '11 03:03

Reznor


People also ask

Can we use node JS on client-side?

js application. In client-side we mainly deal with DOM or web APIs like cookies, but these things don't exist in Node. Other reasons why we cannot use node modules at the client side is that the node uses the CommonJS module system while the browser uses standard ES Modules which has different syntax.

Does node JS run on the client-side or server-side?

Node. js is an application runtime environment that enables using JavaScript (that used to be a client-side programming language) for building server-side applications that have access to the operating system, file system, and everything else to be fully-functional.

What is difference between client-side and server-side scripting?

On the client side, the user is allowed to access the code written after verifying the user's need. Server-side scripting allows the back-end developer to hide the source code from the user. The client-side does not need any interaction with the server.

Can we use node JS and PHP together?

Yes, and yes. Node and Apache / PHP can co-exist on a single server. The only issue you are likely to run into is that they cannot both listen on the same port. HTTP, by default, runs on port 80 and only one process can "listen" on a single port at any one time.


2 Answers

What you need is a telnet (or ssh) server which is written as a NodeJS module.

It needs to understand the telnet protocol, which is richer than a simple character stream. (e.g. it sends messages for terminal (re)sizes and many other events). http://en.wikipedia.org/wiki/Telnet - see the RFCs.

This is confusing because the telnet client is often used to connect to services which just use plain character streams.

As far as I have found, there are no such working modules. Please correct me if you find one.

Netcat does not send any information on terminal type, terminal size or terminal events. These are all necessary for an ncurses-type application.

like image 67
fadedbee Avatar answered Oct 05 '22 09:10

fadedbee


ncurses is a C library that you need to link to in order to call it functions so I don't think its what you can use for your use case.

I'm guessing that by "manipulating ncurses" what you are really after is a way to change the colour of text you are writing to the users, moving up and down the screen, etc.

You maybe able to achieve some of what you want by getting your users to connect via a telnet client that supports ANSI color escape codes for example. Answer to simliar question for producing colour codes here.

like image 40
Maks Avatar answered Oct 05 '22 09:10

Maks