| 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 |
| 8 Tutorial](https://docs.google.com/document/d/1mufrtxTk8w9qa3jcnlgqsYkWlyhwEpc7aW
NaSOks7ug). |
| 9 |
| 7 ## Running the Echo Client & Server | 10 ## Running the Echo Client & Server |
| 8 | 11 |
| 9 ``` | 12 ``` |
| 10 $ ./mojo/tools/mojob.py gn | 13 $ ./mojo/tools/mojob.py gn |
| 11 $ ./mojo/tools/mojob.py build | 14 $ ./mojo/tools/mojob.py build |
| 12 $ ./out/Debug/mojo_shell mojo:echo_client | 15 $ ./out/Debug/mojo_shell mojo:echo_client |
| 13 ``` | 16 ``` |
| 14 You should see output along the lines of: | 17 You should see output along the lines of: |
| 15 | 18 |
| 16 ``` | 19 ``` |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 This server creates an `EchoImpl` object when it is constructed, and for each | 171 This server creates an `EchoImpl` object when it is constructed, and for each |
| 169 call to `Create`, binds the request to this single implementation. A | 172 call to `Create`, binds the request to this single implementation. A |
| 170 `BindingSet` is used so that multiple requests can be bound to the same object. | 173 `BindingSet` is used so that multiple requests can be bound to the same object. |
| 171 | 174 |
| 172 ### Server 3: OneAtATimeServer | 175 ### Server 3: OneAtATimeServer |
| 173 | 176 |
| 174 This server creates an `EchoImpl` object, like the `SingletonServer`, but uses a | 177 This server creates an `EchoImpl` object, like the `SingletonServer`, but uses a |
| 175 single `Binding`, rather than a `BindingSet`. This means that when a new client | 178 single `Binding`, rather than a `BindingSet`. This means that when a new client |
| 176 connects to the OneAtATimeServer, the previous binding is closed, and a new | 179 connects to the OneAtATimeServer, the previous binding is closed, and a new |
| 177 binding is made between the new client and the interface implementation. | 180 binding is made between the new client and the interface implementation. |
| 181 |
| 182 The OneAtATimeServer demonstrates a pattern that should be avoided because it |
| 183 contains a race condition for multiple clients. If a new client binds to the |
| 184 server before the first client managed to call EchoString, the first client's |
| 185 call would cause an error. Unless you have a specific use case for this |
| 186 behavior, it is advised to avoid creating a server like this. |
| OLD | NEW |