03.12.2015 Views

laravel4cookbook

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Embedded Systems 300<br />

21 $this->line("exception: " . $e->getMessage() . ".");<br />

22 });<br />

23 }<br />

24<br />

25 public function fire()<br />

26 {<br />

27 $this->device = fopen($this->argument("device"), "r+");<br />

28 stream_set_blocking($this->device, 0);<br />

29<br />

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

31<br />

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

33 new HttpServer(<br />

34 new WsServer(<br />

35 $this->socket<br />

36 )<br />

37 ),<br />

38 $port<br />

39 );<br />

40<br />

41 $this->info("Listening on port " . $port . ".");<br />

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

43 }<br />

44<br />

45 protected function getArguments()<br />

46 {<br />

47 return [<br />

48 [<br />

49 "device",<br />

50 InputArgument::REQUIRED,<br />

51 "Device to use."<br />

52 ]<br />

53 ];<br />

54 }<br />

55<br />

56 public function __destruct()<br />

57 {<br />

58 if (is_resource($this->device)) {<br />

59 fclose($this->device);<br />

60 }<br />

61 }

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

Saved successfully!

Ooh no, something went wrong!