23 lines
		
	
	
		
			560 B
		
	
	
	
		
			Fortran
		
	
	
	
			
		
		
	
	
			23 lines
		
	
	
		
			560 B
		
	
	
	
		
			Fortran
		
	
	
	
| use "common.ul";
 | |
| 
 | |
| function main(int argc, str[] argv) {
 | |
|   Server s("tcp://0.0.0.0:25565");
 | |
|   bool running = true;
 | |
|   Player[] players = [Player("user", [0.0, 0.0, 0.0], RED)];
 | |
|   while (running) {
 | |
|     if (Client client = s.accept("players")) {
 | |
|       if (Message message = client.get()) {
 | |
|         if (message.t == "close") {
 | |
|           client.close();
 | |
|           running = false;
 | |
|         } else if (message.t == "players") {
 | |
|           client.write(players);
 | |
|         } else {
 | |
|           print("unknown message {message}");
 | |
|         }
 | |
|       }
 | |
|     }
 | |
|   }
 | |
|   exits(nil);
 | |
| }
 |