yii-node-socket icon indicating copy to clipboard operation
yii-node-socket copied to clipboard

I trying example in github but it doesn't show anything result

Open Mamepoker opened this issue 10 years ago • 15 comments

I trying follow this step_1

1.I open index.php?r=nsEventExample/eventListener in new tab step_2

2.I click to sendRoomEvent step_3

  1. and I go back to tab "index.php?r=nsEventExample/eventListener" , It doesn't show result :(

How to fix it

ps. sry to my english.

Mamepoker avatar Oct 30 '14 10:10 Mamepoker

hi, here the bug in the example, need to wrap all code in

socket.onConnect(function () {

});

like in the documentation

oncesk avatar Oct 30 '14 10:10 oncesk

and check if nodejs process is working

$> pgrep node

oncesk avatar Oct 30 '14 10:10 oncesk

hi,

I try simple code this is my code in controller

controller

and my javascript code

myjavascript

It just alert and console "hello 3"

console

I'm not sure in this case. It can't connect to socket.io right ?

Mamepoker avatar Oct 31 '14 06:10 Mamepoker

and I try check nodejs process & start it

startnode

how can I fix it ?

thank you :)

Mamepoker avatar Oct 31 '14 06:10 Mamepoker

Hi, port 3001 is taken, try 3004

oncesk avatar Oct 31 '14 07:10 oncesk

seems like your os is windows and pgrep command does not exists in git bash shell

oncesk avatar Oct 31 '14 07:10 oncesk

your alert('hello 3'); just says that you connected to socket.io and can catch or send events

oncesk avatar Oct 31 '14 07:10 oncesk

hi

I changed port in config/main.php , config/console.php , extensions/yii-node-socket/lib/js/server/server.config.js .

from port 3001 to 3004

and yiic node-socket restart

but when I open index.php?r=nsEventExample/eventListener , I got it

socket io

How to fix it ?

Ps.Sry I'm newbie in websocket :(

Mamepoker avatar Oct 31 '14 07:10 Mamepoker

old url to socket.io.js port 3004 but in console log 3001

you must clear assets

oncesk avatar Oct 31 '14 07:10 oncesk

It really join case on onConnect. :)

Thank you so much :+1:

Mamepoker avatar Oct 31 '14 07:10 Mamepoker

not at all

oncesk avatar Oct 31 '14 08:10 oncesk

hi,

I try send event with php this is my code

trysendmsg

and this is my javascript

javascript

but I don't got any message this is my log

log

I'm not sure, What 's wrong in php side ? or Can I get error Message in php side ?

Thank you

Mamepoker avatar Oct 31 '14 08:10 Mamepoker

=) because event from php very fast and it was executed before php render your template =)

you should emit event in one action you should listen events in javascript on loaded page (before you send event from php) it can be othe browser tab and action

oncesk avatar Oct 31 '14 08:10 oncesk

hi,

Do you have any example ?

Mamepoker avatar Oct 31 '14 08:10 Mamepoker

sorry, but i do not have =)

oncesk avatar Oct 31 '14 09:10 oncesk