Skip to content
← Back to Community
Ask || Server To Index
Profile icon
GatewayDuckYT

Ok So I want to send info from my server file to my index file (views/index.ejs) how do i do this btw i am useing socket.io allready

Voters
Profile icon
GatewayDuckYT
Comments
hotnewtop
Profile icon
finnegan

Remarkable article, it is particularly useful! I quietly began in this, and I'm becoming more acquainted with it better! Delights, keep doing more and extra impressive! Время прибытия в Канаду онлайн

Profile icon
bapexa

A WordPress Commenter says: Hi, this is a comment. To get started with moderating, editing, and deleting comments, please visit ... สล็อตเว็บตรง

Profile icon
Petrikboss

The relocation process to goods or items dispatch it to the one location and offer value-added services like unpacking and rearranging items at another place. Packers and Movers Ghaziabad to Himachal Pradesh

Profile icon
bapexa

Additionally, the seat includes a built-in recline feature that allows you to adjust the angle of the seat to provide your child with a comfortable ride. The Chicco KeyFit 30 reviews is a great choice for parents looking for a safe and comfortable car seat for their children. graco booster with back

Profile icon
Petrikboss

People need touch. It's as simple as that. Without touch, we get frustrated, sick, and stressed. A newborn who's maybe not handled will not thrive. A well done massage takes our significance of feel to a brand new healing level. It can not just relieve tension and tension, it can help rehabilitate a muscle injury. Additionally it may help prevent injury. 서울출장안마

Profile icon
Petrikboss

Allianz packers and Movers provides the best quotes of top Packers and Movers, Office and Home Shifting Household Shifting, Relocation,Movers and Packers, Transportation Service in Thiruvottiyur Chennai. Packers and Movers in Dadar Mumbai

Profile icon
Petrikboss

Picking the best possible match between the car seat and stroller that suits you and your family is quite an overwhelming job. For everyone including newer parents, this one is the toughest job. chicco keyfit 30 compatible stroller

Profile icon
bapexa

원분들께서는 아무런 먹튀검증 절차 없이 토토사이트를 이용하신다는 것에 매우 안타깝게 생각하고 있습니다. 그렇지만 현재도 많은 신규 토토사이트 회원분들께서는 아무렇지 않게 이용을 하는 상황입니다. 사설토토사이트

Profile icon
Petrikboss

Because you are the most important. Be careful and always consult a trusted tarot, there are thousands on the internet, and rest assured, only a few know what they are doing, a friendly advice. We are waiting for you and thank you! Tarot in Seville-Seer in Seville-Tarot reader in Seville of confidence-Alice's Tarot 24 hours telefono de vidente Sevilla

Profile icon
finnegan

Thanks for a wonderful share. Your article has proved your hard work and experience you have got in this field. Brilliant .i love it reading.Nft games

Profile icon
Petrikboss

I know it’s a drastic situation and you have to think on your toes, but you will surely die if you do what you’re thinking of doing. 인도 비자 여권 요구 사항

Profile icon
Abdul-moizmoiz2

Totoglory, a food verification site, spends a lot of time and money to introduce a safe Toto site. However, there are many eat-and-run sites that are popping up every day, and there is a lot of eating-and-running happening. 사설토토사이트

Profile icon
tussiez

server file

const app = require('express')(); const http = require('http').createServer(app); const io = require('socket.io')(http); io.on('connection',function(socket){ socket.emit("Hey you","want a rick roll"); socket.emit("ok","hehe"); }); http.listen(3000,() => { console.log('Hai'); });

The website:
HTML

... other html <script src="/socket.io/socket.io.js"></script>

JavaScript:

const socket = io(); socket.on('Hey you',function(text){ alert(text); })
Profile icon
SixBeeps

Depends on what kind of information, what method of comms, etc.
If you want asynchronous information transmission and you're using socket.io, you can use the emit() function. See this. Otherwise, if you're looking for more of a synchronous method of info transmission, you can make an HTTP GET request with XMLHttpRequest and return the info when the server gets that request.

Profile icon
GatewayDuckYT

@SixBeeps This Dont Work

index.ejs

socket.on('test', function(text) { alert(text) })

server.js

socket.emit('test', 'gamer')
Profile icon
SameeraMurthy

You need to include socket.io in the client side (in index.ejs) and then do

const socket = io();

And make sure you have a socket.io server running.

Profile icon
GatewayDuckYT

@SameeraMurthy i do by from the server file how do i send info to the index file

Profile icon
SameeraMurthy

@GatewayDuckYT you can send info with socketio like this

io.on("connection", (socket) => { socket.emit("greeting", "Hello World"); })

and in the front end do:

socket.on("greeting", (data) => { alert(data) })

use this reference:
https://socket.io/docs/v3/emit-cheatsheet/