Giter Club home page Giter Club logo

Comments (3)

aitte avatar aitte commented on June 2, 2024

This is a good companion to #42 (HTML5 WebSockets).

If both were implemented, socket-based AJAXChat communications would finally be opened up to the world. All modern desktop and mobile browsers support WebSockets, and an accompanying NodeJS server is very easy to install and start on any computer.

End result: Finally switching from slow PHP/JSON back-end to Sockets for everyone!

from ajax-chat.

IngwiePhoenix avatar IngwiePhoenix commented on June 2, 2024

I currently work with nodeJS myself - i use the appJS module (npm install appjs) or http://appjs.org
I am trying to concept a server-side for the chat like you pointed out.
Am 05.02.2013 um 06:25 schrieb aitte [email protected]:

It's true that the Ruby server works well, but if you are looking for a fun and quick-to-write project, there's Node.JS (http://nodejs.org/) which lets you write an ultra-high-performance server in very few lines of code.

It contains libraries for MySQL which makes implementation easy, and passing messages around between connected sockets is super easy too (there are built-in broadcast methods). Check some videos about it. It's fantastically fun and quick to develop for! I know that you could have a NodeJS based server in less than a day.

The question remains: Why write a NodeJS server?

  1. Ultra-high performance (asynchronous threads)
  2. Very quick and fun to write a server in
  3. Exists for every platform and requires a single .exe/bin file (http://nodejs.org/download/)

Especially #3 helps, because the Ruby server requires lots of setup for Ruby itself on Mac OS X and Windows (it's easier on Linux).

With NodeJS, they just have to download Node, and run one of:
./node server.js (mac, linux, unix)
node.exe server.js (windows)


Reply to this email directly or view it on GitHub.

from ajax-chat.

aitte avatar aitte commented on June 2, 2024

Here is exactly what is needed. I am posting this for future reference. Would love to implement it myself, because it's a quick and fun job, but I am way too busy with work administering a network of Cloud servers right now and there's no way I can spare even a second to look at doing this myself.

Server

Core

MySQL driver

  • node-mysql
    • Site: https://github.com/felixge/node-mysql and https://npmjs.org/package/mysql
    • Platforms: All (Win/Mac/Linux/BSD)
    • Strengths/Weaknesses: Easy to install, mature and very stable (has financial and development support from corporate sponsors), built in Javascript using Node which makes it fast while still supporting every OS and requiring no extra libraries, lots of corporate applications use this one. This is the one to choose for the server, it's the least hassle to install for end-users and is fast and stable!

Client/Server Socket Communications

  • Socket.IO
    • Site: http://socket.io and https://npmjs.org/package/socket.io
    • Platforms: All (Win/Mac/Linux/BSD)
    • Strengths/Weaknesses: Provides a server/client socket abstraction that allows messages to pass back and forth effortlessly. Supports every browser (uses Flash automatically if the browser doesn't support WebSockets). You run it in both the client and the server. No weaknesses.

Client

Client/Server Socket Communications

  • Socket.IO
    • Site: http://socket.io and https://npmjs.org/package/socket.io
    • Platforms: All (Win/Mac/Linux/BSD)
    • Strengths/Weaknesses: Provides a server/client socket abstraction that allows messages to pass back and forth effortlessly. Supports every browser (uses Flash automatically if the browser doesn't support WebSockets). You run it in both the client and the server. No weaknesses.

Installing the Server (All Platforms)

  • Download and Install NodeJS for your platform using the INSTALL button at http://nodejs.org
  • Install the required server libraries
    • node-mysql: npm install mysql
    • socket.io: npm install socket.io
    • _Note: On Windows, the npm tool is in C:\Program Files\nodejs_
  • Start the server
    • node server.js
  • That's it! Super easy for anyone to run a socket chat server!

Alright, so what to do to make the server and client talk to each other?

  • Replace the current, hacky Flash-socket code with Socket.io on both the client and server. The client's browser will automatically be able to talk to the server regardless of browser used, and will use either ultra-fast WebSockets, or Socket.io's Flash transport if no WebSockets are available.
  • To learn more about Socket.IO client/server and Node, view this short tutorial (it's very simple): http://java.dzone.com/articles/getting-started-socketio-and
  • These are the basic step by step components to making this a reality:
    • Write a Node.JS server that uses Socket.IO and make it talk back/forth with the client's Socket.IO
    • When that works, add the MySQL library to the server and make it write/read the database
    • That's it! No more need for Ruby or PHP. Server requires just Node and is easy to install on any platform.

Bonus: Getting rid of the Flash dependency for audio too!

Bonus: Getting rid of Web server dependency!

  • Use http://expressjs.com to build the web-server into the Node.JS server. That way, the Node server can reply on port 80 with the HTML/Javascript/Images that the client needs, and the client then connects to the chat-socket port after that.
  • That's it, no more Flash, no more PHP, no more Ruby, no more Apache/webserver. Just a single server script that works on every platform and hosts the entire chat application.
  • The only external dependency that remains is MySQL, which is fine and easy to install. Alternatively, one could switch the system over to Node+NoSQL (http://www.couchbase.com/why-nosql/nosql-database) which is even faster and lighter than MySQL.

from ajax-chat.

Related Issues (20)

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.