Tk-Based Peer Chat
Back on Day 19 we toyed with the idea of chat scripts allowing people to type messages to each other over the Internet. Our implementation at the time was really barely functional; its main drawback was that any conversation had to be sequential, meaning that the parties—let's refer them to Alice and Bob—had to take turns speaking. Once Bob had sent a message, he was not allowed to send another one until Alice replied. Today we remedy that problem by resolving two little problems.
When Alice is typing in a message, how can she receive a message from Bob? It would seem her script needs to be evaluating two separate gets expressions simultaneously, one of them referring to her keyboard and the other to a network socket.
If a message ...
Get Sams Teach Yourself Ruby in 21 Days now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.