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.

Embedded Systems 294<br />

34 $this->emitter->emit("open");<br />

35 }<br />

36<br />

37 public function onMessage(Connection $connection, $message)<br />

38 {<br />

39 $this->emitter->emit("message", [$message]);<br />

40 }<br />

41<br />

42 public function onClose(Connection $connection)<br />

43 {<br />

44 $this->connection = null;<br />

45 }<br />

46<br />

47 public function onError(Connection $connection, Exception $e)<br />

48 {<br />

49 $this->emitter->emit("error", [$e]);<br />

50 }<br />

51<br />

52 public function send($message)<br />

53 {<br />

54 if ($this->connection)<br />

55 {<br />

56 $this->connection->send($message);<br />

57 }<br />

58 }<br />

59 }<br />

This file should be saved as workbench/formativ/embedded/src/Formativ/Embedded/Socket.php.<br />

.<br />

.<br />

The Socket class only has room for a single connection. Feel free to change this so that it can handle<br />

any number of controlling connections.

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

Saved successfully!

Ooh no, something went wrong!