oncesk / yii-node-socket

66 stars 46 forks source link

How to create a logout frame #79

Open wcg777 opened 8 years ago

wcg777 commented 8 years ago

I found a logoutFrame in server events folder. I added authorize client in user component afterLogin event, then I failed to create logout frame when user log out in yii. can you show me how to create this logoutFrame?

oncesk commented 8 years ago

Hello, seems like i forgot add it to FrameFactory, i am sorry)

just now i added logout frame creation from FrameFactory

changes in branches

update you composer dependencies in case when you use dev-master, or change version to 2.0.8

Please, after checked it let me know if my changes does not trigger some error

wcg777 commented 8 years ago

I'm working on yii 1.1.17. And how to call logout?

public function actionLogout() { $user = yii::app()->user; $id = $user->id; $user->logout();
$frame = Yii::app()->nodeSocket->getFrameFactory()->createLogoutFrame(); $frame->setUserId($id); $frame->send(); $this->redirect(Yii::app()->controller->module->returnLogoutUrl); }

It doesn't work. When user logout, he still can receive notifications for him.

oncesk commented 8 years ago

Hi, sorry for long response

can you debug this case in js? path to js script lib/js/server/events/server/logout.js can you check if we are enter to handler method, you can use

console.log(frame);

and see output into you console or in log file

wcg777 commented 8 years ago

info: socket error Error: read ECONNRESET at exports._errnoException (util.js:856:11) at TCP.onread (net.js:546:26) info: transport end (undefined) debug: set close timeout for client -UKwm3EhMziB8bYYBVuN debug: cleared close timeout for client -UKwm3EhMziB8bYYBVuN debug: cleared heartbeat interval for client -UKwm3EhMziB8bYYBVuN

I think it's working now.