1 Connecting Two ImaginesThis tutorial is an introduction to using a network in Imagine. We will learn how to:
1. Let us launch two Imagines. It is necessary to launch them with /m command line options: 2. Restore their windows to normal size and arrange them next to each other: Now we have two windows of Imagine - let us call them the Left and the Right Imagine. 3. Now, we connect these Imagines together using the Net object. This connection is done locally on the same computer. It allows easy testing and observing what is happening. We start with the Left Imagine window. It will be the server Imagine project. To make it server we type the following commands into the command line:
Networking object net1 allows us to connect two or more Imagines together, to send data between them, check the network status etc. At this moment we may connect the Right Imagine. The Right Imagine will be the client Imagine and it will be connected to the server. We write to the Right Imagine:
First instruction has created new networking object named net1 in the Right Imagine. Its style is client, that is, it behaves as a client connected to the local computer. Its server setting is localhost. Second instruction has activated net1 object in the Right Imagine and has connected it to the network. 4. At this moment we have the Left Imagine and Right Imagine connected together. We may check this connection by asking for the list of currently connected users. We can type the following instruction into the Left and Right Imagine as well:
If everything works correctly, the result of this command should be [server client]. 5. It is possible to send a simple text message via net. Let us send "Hello" text from the Right Imagine to the Left Imagine (of course, the same is possible vice-versa as well):
This text was sent to all currently connected users except the sender himself/herself (now, it is only the Left Imagine). Now, the Left Imagine should display received message:
This command will show [Hello] in the text screen of the Left Imagine. ConclusionIt is very easy to connect two Imagines which are running in one computer in parallel. When you are going to send and receive texts, two commands are sufficient to know - namely, send and message. Connecting two Imagines locally is very useful for getting first experience and running your own introductory experiments. We will see that establishing connection between two computers is very similar to the steps described above. |