Code Monkey home page Code Monkey logo

Comments (3)

theturtle32 avatar theturtle32 commented on July 21, 2024

You have to call JSON.stringify(object) to convert the object to JSON before passing the resulting string to send()

The websocket library will not convert objects to JSON for you.

Sent from my iPhone

On Nov 22, 2011, at 1:15 PM, [email protected] wrote:

Hi, i have issues with that when i'm sending a json object from my website to the websocket server, it just gets the '[object Object]' string, and not the real object, and vica versa, so i can't send any json object to the client from the server.


Reply to this email directly or view it on GitHub:
#21

from websocket-node.

ketting00 avatar ketting00 commented on July 21, 2024

I have this issue too. How do I send an image/webp file to a server. Here's my code.

console.log((new Date()) + ' Connection accepted.');
connection.on('message', function(message) {
if (message) {
console.log('Received Message: ' + message);
connection.send(message);
}
});

Thanks,
Ket

from websocket-node.

theturtle32 avatar theturtle32 commented on July 21, 2024

This code is entirely unrelated to sending images. WebSocket-Node just provides a way to establish WebSocket communications with the browser. As the developer of your own application, you are responsible for what is transmitted over that connection and how it is handled. There is no built-in functionality in WebSocket for dealing with images or files.

from websocket-node.

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.