Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Created by alicj_390xsny on 15.03.2019.
- */
- import org.apache.xmlrpc.WebServer;
- public class serwerRPC {
- public Integer echo(int x, int y){
- return new Integer(x+y);
- }
- public int execAsy(int x){
- System.out.println("... wywolano asy - odliczam");
- try{
- Thread.sleep(x);
- } catch (InterruptedException e) {
- e.printStackTrace();
- Thread.currentThread().interrupt();
- }
- System.out.println("... asy - koniec odliczania");
- return (123);
- }
- public int modyfication(String text, String number){
- int counter = Integer.parseInt(number);
- try {
- for (int i=0; i<counter; i++){
- System.out.println(text);
- Thread.sleep(1000);
- }
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- return (123);
- }
- public static void main(String[] args) {
- try{
- System.out.println("Startuje serwer XML-RPC...");
- int port = 10000;
- WebServer server = new WebServer(port);
- server.addHandler("MojSerwer", new serwerRPC());
- server.start();
- System.out.println("Serwer wystartowal pomyslnie");
- System.out.println("Nasluchuje na porcie: " + port);
- System.out.println("Aby zatrzymać serwer nacisnij ctrl+c");
- }
- catch(Exception exception){
- System.err.println("Serwer XML-RPC: " + exception);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement