javascript - Send a file in socket.io without changing the user's window location -
i looking see if there way send html file socket.io connection without disconnecting them , changing window location. right have set if tries access website prompted enter name. when name entered , user presses play sent /game directory on website. emit name along connection info. @ moment when connect /game directory disconnects user causing information (including name) removed player list. when player joins onto /game directory have name of null , info entirely new info coordinates , things. here code use detect request /game:
//sends home page asks name. app.get('/',function(req, res){ res.sendfile(__dirname + "/client/home.html"); }); //sends game file when /game requested app.get('/game',function(req, res){ res.sendfile(__dirname + "/client/game.html"); });
is there way stop user disconnecting when change game screen? way can keep info? or there else can fix problem?
every time change uri in browser should reconnect websocket connection.
my advice use single page aplication. backend send data socket or/and rest. frontend render data backend. have view on backend , have problem reconnecting web sockets.
Comments
Post a Comment