home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-10-07 | 1.2 KB | 52 lines |
- // MuReceiver.java
- // waiting for avatars' position from server and update them
- import vrml.field.*;
-
- import java.net.*;
- import java.io.*;
- import java.util.*;
-
- class MuReceiver extends Thread {
- DataInputStream in = null;
- MuClient muclient;
-
- MuReceiver(DataInputStream i, MuClient muc){
- super("MuReceiver");
-
- in = i;
- muclient = muc; // to call methods of MuClient class
- this.start(); // start this thread
- }
-
- public void run(){
- int id;
- int command;
- float x, y, z, r;
-
- while(true){
- try {
- // receive client's id and its position from server
- id = in.readInt();
- command = in.readInt();
- x = in.readFloat();
- y = in.readFloat();
- z = in.readFloat();
-
- if(MuProtocol.MOVE == command){
- // update position
- muclient.updatePosition(id, x, y, z);
- }else{
- r = in.readFloat();
-
- // update orientation
- muclient.updateOrientation(id, x, y, z, r);
- }
- System.out.println(id + ": " + x + " " + y + " " + z);
- } catch (IOException e) {
- e.printStackTrace();
- return;
- }
- }
- }
- }
-