Guest User

Untitled

a guest
May 7th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. ----testServer.java----
  2.  
  3. import java.util.Properties;
  4. import org.python.util.PythonInterpreter;
  5.  
  6. public class Server {
  7.  
  8. public static void main(String args[]){
  9. Properties props = new Properties();
  10. props.setProperty("python.path", "C:\\panda3d-1.7.2\\python\\lib\\site-packages");
  11. PythonInterpreter.initialize(System.getProperties(), props, new String[] {""});
  12. PythonInterpreter python = new PythonInterpreter();
  13. python.execfile("src\\game\\Server.py");
  14. }
  15. }
  16.  
  17.  
  18. ----Server.py----
  19. from twisted.internet import reactor, protocol
  20.  
  21. user=None
  22. password=None
  23. clients=[]
  24.  
  25. class listen(protocol.Protocol):
  26.  
  27. def connectionMade(self):
  28. client = self.transport.getPeer();
  29. print str(client) + " connected"
  30. self.transport.write("test")
  31.  
  32. class factory(protocol.ServerFactory):
  33. protocol=listen
  34.  
  35. def main():
  36. reactor.listenTCP(5000,factory())
  37. reactor.run()
  38.  
  39. if __name__ == '__main__':
  40. main()
Add Comment
Please, Sign In to add comment