oncesk / yii-node-socket

66 stars 46 forks source link

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

Open Mamepoker opened 10 years ago

Mamepoker commented 10 years ago

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.

oncesk commented 10 years ago

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

socket.onConnect(function () {

});

like in the documentation

oncesk commented 10 years ago

and check if nodejs process is working

$> pgrep node
Mamepoker commented 10 years ago

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 commented 10 years ago

and I try check nodejs process & start it

startnode

how can I fix it ?

thank you :)

oncesk commented 10 years ago

Hi, port 3001 is taken, try 3004

oncesk commented 10 years ago

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

oncesk commented 10 years ago

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

Mamepoker commented 10 years ago

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 :(

oncesk commented 10 years ago

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

you must clear assets

Mamepoker commented 10 years ago

It really join case on onConnect. :)

Thank you so much :+1:

oncesk commented 10 years ago

not at all

Mamepoker commented 10 years ago

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

oncesk commented 10 years ago

=) 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

Mamepoker commented 10 years ago

hi,

Do you have any example ?

oncesk commented 10 years ago

sorry, but i do not have =)