| OLD | NEW |
| 1 Example Echo Client & Server | 1 Example Echo Client & Server |
| 2 ==== | 2 ==== |
| 3 | 3 |
| 4 This echo client/server demonstrate how to create and use a mojom interface, | 4 This echo client/server demonstrate how to create and use a mojom interface, |
| 5 as well as demonstrating one way to communicate between mojo applications. | 5 as well as demonstrating one way to communicate between mojo applications. |
| 6 | 6 |
| 7 For a deeper dive into this code, refer to the [Mojo | 7 For a deeper dive into this code, refer to the [Mojo |
| 8 Tutorial](https://docs.google.com/document/d/1mufrtxTk8w9qa3jcnlgqsYkWlyhwEpc7aW
NaSOks7ug). | 8 Tutorial](https://docs.google.com/document/d/1mufrtxTk8w9qa3jcnlgqsYkWlyhwEpc7aW
NaSOks7ug). |
| 9 | 9 |
| 10 ## Running the Echo Client & Server | 10 ## Running the Echo Client & Server |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 | 127 |
| 128 echo_server.cc contains three different types of servers, though only one can be | 128 echo_server.cc contains three different types of servers, though only one can be |
| 129 used at a time. To try changing the server, uncomment one of the lines in | 129 used at a time. To try changing the server, uncomment one of the lines in |
| 130 MojoMain. These different `ApplicationDelegate` derivations demonstrate | 130 MojoMain. These different `ApplicationDelegate` derivations demonstrate |
| 131 different ways in which incoming requests can be handled. | 131 different ways in which incoming requests can be handled. |
| 132 | 132 |
| 133 All three servers, being `ApplicationDelegate` derivations, implement | 133 All three servers, being `ApplicationDelegate` derivations, implement |
| 134 `ConfigureIncomingConnection` in the same way: | 134 `ConfigureIncomingConnection` in the same way: |
| 135 | 135 |
| 136 ``` | 136 ``` |
| 137 connection->GetServiceProviderImpl().AddService<Echo>( | 137 service_provider_impl->AddService<Echo>( |
| 138 [this](const mojo::ConnectionContext& connection_context, | 138 [this](const mojo::ConnectionContext& connection_context, |
| 139 mojo::InterfaceRequest<Echo> echo_request) { | 139 mojo::InterfaceRequest<Echo> echo_request) { |
| 140 ... | 140 ... |
| 141 }); | 141 }); |
| 142 ``` | 142 ``` |
| 143 | 143 |
| 144 This should be read as "For any incoming connections to this server, use the | 144 This should be read as "For any incoming connections to this server, use the |
| 145 given lambda function use `this` to create the Echo interface". | 145 given lambda function use `this` to create the Echo interface". |
| 146 | 146 |
| 147 ### EchoImpl: The Interface Implementation | 147 ### EchoImpl: The Interface Implementation |
| (...skipping 28 matching lines...) Expand all Loading... |
| 176 This server creates an `EchoImpl` object, like the `SingletonServer`, but uses a | 176 This server creates an `EchoImpl` object, like the `SingletonServer`, but uses a |
| 177 single `Binding`, rather than a `BindingSet`. This means that when a new client | 177 single `Binding`, rather than a `BindingSet`. This means that when a new client |
| 178 connects to the OneAtATimeServer, the previous binding is closed, and a new | 178 connects to the OneAtATimeServer, the previous binding is closed, and a new |
| 179 binding is made between the new client and the interface implementation. | 179 binding is made between the new client and the interface implementation. |
| 180 | 180 |
| 181 The OneAtATimeServer demonstrates a pattern that should be avoided because it | 181 The OneAtATimeServer demonstrates a pattern that should be avoided because it |
| 182 contains a race condition for multiple clients. If a new client binds to the | 182 contains a race condition for multiple clients. If a new client binds to the |
| 183 server before the first client managed to call EchoString, the first client's | 183 server before the first client managed to call EchoString, the first client's |
| 184 call would cause an error. Unless you have a specific use case for this | 184 call would cause an error. Unless you have a specific use case for this |
| 185 behavior, it is advised to avoid creating a server like this. | 185 behavior, it is advised to avoid creating a server like this. |
| OLD | NEW |