Zoadian

Untitled

Jun 17th, 2012
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
D 0.85 KB | None | 0 0
  1. import net;
  2.  
  3. import std.socket;
  4. import std.stdio;
  5. import std.conv;
  6. import core.thread;
  7.  
  8. import messages;
  9.  
  10.  
  11.  
  12. int main()
  13. {
  14.     auto con = Connection.connect(new InternetAddress("127.0.0.1", 9861));
  15.     while(true)
  16.     {
  17.         {//SEND
  18.             MsgCharacterUpdate msg;
  19.             msg.position = [12,13,14];
  20.             msg.orientation = [55,66,77,88];
  21.             msg.scale = [1,2,3];
  22.             writeln("SEND:\n", msg.toString());    
  23.             con.send(1234);
  24.             con.send(msg);
  25.             writeln();
  26.         }
  27.        
  28.         {//RECEIVE
  29.             writeln("RECV:");
  30.             con.receive(
  31.                 (MsgCharacterUpdate msg){ writeln("MsgCharUpdate: ", msg); },
  32.                 (int i){writeln("INT: ", i);}
  33.             );
  34.         }
  35.        
  36.         Thread.sleep( dur!("msecs")( 1000 ) );
  37.     }
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment