Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrating Socket.io and passing values to cloud code #4013

Closed
skparticles opened this issue Jul 12, 2017 · 2 comments
Closed

Integrating Socket.io and passing values to cloud code #4013

skparticles opened this issue Jul 12, 2017 · 2 comments

Comments

@skparticles
Copy link

skparticles commented Jul 12, 2017

I have successfully integrated socket.io at index.js and able to receive messages through the socket connection.

How to pass the data from socket message to parse server cloud function
cloud/main.js function messageFromSocket(message);

index.js

//Parse Server Initialization
var api = new ParseServer({
    databaseURI: databaseUri,
......
});

//SocketIO
var app = require('express')();
var server = require('http').createServer(app);
var io = require('socket.io')(server);
io.on('connection', function () { /* … */
});
server.listen(3000);
global._io = require('socket.io')(httpServer);
_io.on('connection', (socket) => {
    console.log('Client connected');

//Send Message to Emitter
    socket.on('message', function (data, fun) {
        console.log("Message Received");
       //Send this message to parse server cloud function  
        fun("success");
    });
}

cloud/main.js

function receivedMessageFromSocket(message){
   //Then this will be saved to data base
}
@natanrolnik
Copy link
Contributor

Use Parse.Cloud.run("yourFunction").

See more here and here.

@skparticles
Copy link
Author

@natanrolnik Thankyou

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants