03.12.2015 Views

laravel4cookbook

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Real Time Chat 186<br />

81 $this->chat->getEmitter()->on("name", $name);<br />

82<br />

83 $error = function(UserInterface $user, $exception)<br />

84 {<br />

85 $message = $exception->getMessage();<br />

86<br />

87 $this->line("<br />

88 User encountered an exception:<br />

89 " . $message . "<br />

90 .<br />

91 ");<br />

92 };<br />

93<br />

94 $this->chat->getEmitter()->on("error", $error);<br />

95 }<br />

96<br />

97 public function fire()<br />

98 {<br />

99 $port = (integer) $this->option("port");<br />

100<br />

101 if (!$port)<br />

102 {<br />

103 $port = 7778;<br />

104 }<br />

105<br />

106 $server = IoServer::factory(<br />

107 new HttpServer(<br />

108 new WsServer(<br />

109 $this->chat<br />

110 )<br />

111 ),<br />

112 $port<br />

113 );<br />

114<br />

115 $this->line("<br />

116 Listening on port<br />

117 " . $port . "<br />

118 .<br />

119 ");<br />

120<br />

121 $server->run();<br />

122 }

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!