GithubHelp home page GithubHelp logo

jnembhard / tcpserver Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 13 KB

A client that connects with a TCP server to perform actions on 30x30 rendered canvas rendered in the CLI.

JavaScript 100.00%

tcpserver's Introduction

TCP Server

I've created a personalClient.js and tcp.js file. The purpose of the files is to show communication between the TCP server and the client. It outputs commands for the cursor position and drawing instructions on a 30 x 30 canvas.

Setup

  1. Download the latest version of node.js for your Operating System.
  2. Next, download the latest version of nodemon.
    • This can be used to auto restart the server and client.
  3. Run npm install inside the TCP Server Canvas folder from the command line.
  4. Open two separate command line terminals and run the following script:
    • Terminal 1:

      npm run server
    • Terminal 2:

      npm run client

How To Enter Commands

You will be presented with a "Enter a command: " prompt on the client side. The functions receive a response from the server based on the command criteria from the client. After each command, press enter to execute.

NOTE: The default starting position is (x = 15, y = 15).

Commands Include:

  • steps (n): moves the cursor n number of steps forward in a specified direction.

  • left (n) and right (n): turns you to a specified direction.

    • You can move in 8 different directions:
      1. North
      2. North East
      3. East
      4. South East
      5. South
      6. South West
      7. West
      8. North West

    Examples:

    • Typing "steps 10" will move you 10 paces forward from the current direction.

      Move cursor forward 10 units.
      Current position is: (15,5) facing South.
    • Starting at direction 1 (North), and typing "right 4"

      Turn the cursor right 4 units.
      Current Direction is: 5 facing South.
  • hover, draw, eraser: This changes the drawing mode of the canvas brush.

  • coord: returns Coordinates (x, y) to the Client.

  • render: prints the most up to date canvas in the Command Line Interface (CLI).

  • clear: sets the canvas back to its original state.

  • quit: closes the connection to the server.

Functions

Additional functions and created variables needed for both the server and the client are presented in the javascript_index folder as the functions.js file and exported to their associated spaces.

Additional Information

If you would like to watch the updates on the server side, I've included a console.log() to do just that!

{ x: 15, y: 5, direction: 5, array: ['right 4', 'steps 10'] }

The client can retrieve all this information themselves if they wish, but it helps to keep track of that information on the server side as well.

Roadmap

  • Future updates for a project like this could include a more sophisticated auto-drawing feature directly in the CLI.

tcpserver's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.