NODEJS How to block sending socket.emit on web browser?












-2















enter image description here



How to block sending socket.emit on browser ?



server

io.on('connection', function (socket) {

socket.on('singupCheck', function (msg) {
console.log(msg);
});
});

Browser console

var socket = io();
socket.emit('singupCheck','test');









share|improve this question




















  • 2





    Please share your code as text (not image) and be specific at which point you're having trouble.

    – vahdet
    Nov 14 '18 at 12:30






  • 2





    Not clear what you asking?

    – Sadikhasan
    Nov 14 '18 at 12:30











  • My problem; Sending socket.emit codes on web browser.

    – Yusuf Civa
    Nov 14 '18 at 12:34











  • Is there any error or what is your actual issue?

    – Sadikhasan
    Nov 14 '18 at 12:35











  • I want to stop this.Users should not send socket.emit using the browser.

    – Yusuf Civa
    Nov 14 '18 at 12:43
















-2















enter image description here



How to block sending socket.emit on browser ?



server

io.on('connection', function (socket) {

socket.on('singupCheck', function (msg) {
console.log(msg);
});
});

Browser console

var socket = io();
socket.emit('singupCheck','test');









share|improve this question




















  • 2





    Please share your code as text (not image) and be specific at which point you're having trouble.

    – vahdet
    Nov 14 '18 at 12:30






  • 2





    Not clear what you asking?

    – Sadikhasan
    Nov 14 '18 at 12:30











  • My problem; Sending socket.emit codes on web browser.

    – Yusuf Civa
    Nov 14 '18 at 12:34











  • Is there any error or what is your actual issue?

    – Sadikhasan
    Nov 14 '18 at 12:35











  • I want to stop this.Users should not send socket.emit using the browser.

    – Yusuf Civa
    Nov 14 '18 at 12:43














-2












-2








-2








enter image description here



How to block sending socket.emit on browser ?



server

io.on('connection', function (socket) {

socket.on('singupCheck', function (msg) {
console.log(msg);
});
});

Browser console

var socket = io();
socket.emit('singupCheck','test');









share|improve this question
















enter image description here



How to block sending socket.emit on browser ?



server

io.on('connection', function (socket) {

socket.on('singupCheck', function (msg) {
console.log(msg);
});
});

Browser console

var socket = io();
socket.emit('singupCheck','test');






javascript node.js






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 14 '18 at 12:46







Yusuf Civa

















asked Nov 14 '18 at 12:28









Yusuf CivaYusuf Civa

11




11








  • 2





    Please share your code as text (not image) and be specific at which point you're having trouble.

    – vahdet
    Nov 14 '18 at 12:30






  • 2





    Not clear what you asking?

    – Sadikhasan
    Nov 14 '18 at 12:30











  • My problem; Sending socket.emit codes on web browser.

    – Yusuf Civa
    Nov 14 '18 at 12:34











  • Is there any error or what is your actual issue?

    – Sadikhasan
    Nov 14 '18 at 12:35











  • I want to stop this.Users should not send socket.emit using the browser.

    – Yusuf Civa
    Nov 14 '18 at 12:43














  • 2





    Please share your code as text (not image) and be specific at which point you're having trouble.

    – vahdet
    Nov 14 '18 at 12:30






  • 2





    Not clear what you asking?

    – Sadikhasan
    Nov 14 '18 at 12:30











  • My problem; Sending socket.emit codes on web browser.

    – Yusuf Civa
    Nov 14 '18 at 12:34











  • Is there any error or what is your actual issue?

    – Sadikhasan
    Nov 14 '18 at 12:35











  • I want to stop this.Users should not send socket.emit using the browser.

    – Yusuf Civa
    Nov 14 '18 at 12:43








2




2





Please share your code as text (not image) and be specific at which point you're having trouble.

– vahdet
Nov 14 '18 at 12:30





Please share your code as text (not image) and be specific at which point you're having trouble.

– vahdet
Nov 14 '18 at 12:30




2




2





Not clear what you asking?

– Sadikhasan
Nov 14 '18 at 12:30





Not clear what you asking?

– Sadikhasan
Nov 14 '18 at 12:30













My problem; Sending socket.emit codes on web browser.

– Yusuf Civa
Nov 14 '18 at 12:34





My problem; Sending socket.emit codes on web browser.

– Yusuf Civa
Nov 14 '18 at 12:34













Is there any error or what is your actual issue?

– Sadikhasan
Nov 14 '18 at 12:35





Is there any error or what is your actual issue?

– Sadikhasan
Nov 14 '18 at 12:35













I want to stop this.Users should not send socket.emit using the browser.

– Yusuf Civa
Nov 14 '18 at 12:43





I want to stop this.Users should not send socket.emit using the browser.

– Yusuf Civa
Nov 14 '18 at 12:43












1 Answer
1






active

oldest

votes


















1














I think you can't block emit function on socket.io in the console.



But, for example, you can check data on the Node.js side and then decide what you need to do.



For example:



socket.on('event', (data) => {
if (!data) {
throw new Error('Empty data');
}

//do something
});


For this case you will secure your event for empty data.
Also you can check type of expected data.






share|improve this answer
























  • Yes, I cant block emit function on socket.io in the console.How do I know if the incoming request comes from the user or the console? Is there an available parameter for this?

    – Yusuf Civa
    Nov 14 '18 at 12:56











  • @YusufCiva Unfortunately, this parameter is not provided by the library: socket.io/docs/client-api/…

    – Konstantin Kudelko
    Nov 14 '18 at 13:20











  • @Kunstantin Kudelko thank you.

    – Yusuf Civa
    Nov 14 '18 at 13:52











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53300274%2fnodejs-how-to-block-sending-socket-emit-on-web-browser%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














I think you can't block emit function on socket.io in the console.



But, for example, you can check data on the Node.js side and then decide what you need to do.



For example:



socket.on('event', (data) => {
if (!data) {
throw new Error('Empty data');
}

//do something
});


For this case you will secure your event for empty data.
Also you can check type of expected data.






share|improve this answer
























  • Yes, I cant block emit function on socket.io in the console.How do I know if the incoming request comes from the user or the console? Is there an available parameter for this?

    – Yusuf Civa
    Nov 14 '18 at 12:56











  • @YusufCiva Unfortunately, this parameter is not provided by the library: socket.io/docs/client-api/…

    – Konstantin Kudelko
    Nov 14 '18 at 13:20











  • @Kunstantin Kudelko thank you.

    – Yusuf Civa
    Nov 14 '18 at 13:52
















1














I think you can't block emit function on socket.io in the console.



But, for example, you can check data on the Node.js side and then decide what you need to do.



For example:



socket.on('event', (data) => {
if (!data) {
throw new Error('Empty data');
}

//do something
});


For this case you will secure your event for empty data.
Also you can check type of expected data.






share|improve this answer
























  • Yes, I cant block emit function on socket.io in the console.How do I know if the incoming request comes from the user or the console? Is there an available parameter for this?

    – Yusuf Civa
    Nov 14 '18 at 12:56











  • @YusufCiva Unfortunately, this parameter is not provided by the library: socket.io/docs/client-api/…

    – Konstantin Kudelko
    Nov 14 '18 at 13:20











  • @Kunstantin Kudelko thank you.

    – Yusuf Civa
    Nov 14 '18 at 13:52














1












1








1







I think you can't block emit function on socket.io in the console.



But, for example, you can check data on the Node.js side and then decide what you need to do.



For example:



socket.on('event', (data) => {
if (!data) {
throw new Error('Empty data');
}

//do something
});


For this case you will secure your event for empty data.
Also you can check type of expected data.






share|improve this answer













I think you can't block emit function on socket.io in the console.



But, for example, you can check data on the Node.js side and then decide what you need to do.



For example:



socket.on('event', (data) => {
if (!data) {
throw new Error('Empty data');
}

//do something
});


For this case you will secure your event for empty data.
Also you can check type of expected data.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 14 '18 at 12:50









Konstantin KudelkoKonstantin Kudelko

1278




1278













  • Yes, I cant block emit function on socket.io in the console.How do I know if the incoming request comes from the user or the console? Is there an available parameter for this?

    – Yusuf Civa
    Nov 14 '18 at 12:56











  • @YusufCiva Unfortunately, this parameter is not provided by the library: socket.io/docs/client-api/…

    – Konstantin Kudelko
    Nov 14 '18 at 13:20











  • @Kunstantin Kudelko thank you.

    – Yusuf Civa
    Nov 14 '18 at 13:52



















  • Yes, I cant block emit function on socket.io in the console.How do I know if the incoming request comes from the user or the console? Is there an available parameter for this?

    – Yusuf Civa
    Nov 14 '18 at 12:56











  • @YusufCiva Unfortunately, this parameter is not provided by the library: socket.io/docs/client-api/…

    – Konstantin Kudelko
    Nov 14 '18 at 13:20











  • @Kunstantin Kudelko thank you.

    – Yusuf Civa
    Nov 14 '18 at 13:52

















Yes, I cant block emit function on socket.io in the console.How do I know if the incoming request comes from the user or the console? Is there an available parameter for this?

– Yusuf Civa
Nov 14 '18 at 12:56





Yes, I cant block emit function on socket.io in the console.How do I know if the incoming request comes from the user or the console? Is there an available parameter for this?

– Yusuf Civa
Nov 14 '18 at 12:56













@YusufCiva Unfortunately, this parameter is not provided by the library: socket.io/docs/client-api/…

– Konstantin Kudelko
Nov 14 '18 at 13:20





@YusufCiva Unfortunately, this parameter is not provided by the library: socket.io/docs/client-api/…

– Konstantin Kudelko
Nov 14 '18 at 13:20













@Kunstantin Kudelko thank you.

– Yusuf Civa
Nov 14 '18 at 13:52





@Kunstantin Kudelko thank you.

– Yusuf Civa
Nov 14 '18 at 13:52


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53300274%2fnodejs-how-to-block-sending-socket-emit-on-web-browser%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Xamarin.iOS Cant Deploy on Iphone

Glorious Revolution

Dulmage-Mendelsohn matrix decomposition in Python