codethief / virtualme (http://codeartists.org/)
No description has been added.
Clone this repository (size: 36.9 KB): HTTPS / SSH
$ hg clone http://bitbucket.org/codethief/virtualme/
| commit 0: | e5421f497d75 |
| branch: | default |
(no commit message)
Changed (Δ3.0 KB):
raw changeset »
docs/protocol.xml (67 lines added, 0 lines removed)
src/core/Request.java (34 lines added, 0 lines removed)
src/core/ServerProcess.java (26 lines added, 0 lines removed)
src/core/VirtualMe.java (17 lines added, 0 lines removed)
Up to file-list docs/protocol.xml:
1 |
<?xml version="1.0" encoding="UTF-8" ?> |
|
2 |
||
3 |
<virtualme xmlns="http://codeartists.org/virtualme/protocol/core"> |
|
4 |
<info> |
|
5 |
<host></host> |
|
6 |
<software></software> |
|
7 |
</info> |
|
8 |
<clientRequest> |
|
9 |
<connection persistent="true" /> |
|
10 |
<intents> |
|
11 |
<sign-in> |
|
12 |
<username></username> |
|
13 |
<password></password> |
|
14 |
<key-encrypted></key-encrypted> |
|
15 |
</sign-in> |
|
16 |
||
17 |
||
18 |
||
19 |
<register> |
|
20 |
<username></username> |
|
21 |
<password></password> |
|
22 |
<publickey></publickey> |
|
23 |
||
24 |
<realname></realname> |
|
25 |
<email-address></email-address> |
|
26 |
</register> |
|
27 |
||
28 |
||
29 |
<contact-exists username="" /> |
|
30 |
||
31 |
||
32 |
<create-contact> |
|
33 |
<username></username> |
|
34 |
<host></host> |
|
35 |
<nickname></nickname> |
|
36 |
</create-contact> |
|
37 |
||
38 |
<delete-contact> |
|
39 |
<username></username> |
|
40 |
<host></host> |
|
41 |
</delete-contact> |
|
42 |
||
43 |
||
44 |
||
45 |
||
46 |
||
47 |
||
48 |
<!-- the following intents will need admin rights: --> |
|
49 |
<sudo username=""> |
|
50 |
<intents> |
|
51 |
||
52 |
</intents> |
|
53 |
</sudo> |
|
54 |
||
55 |
<delete-user> |
|
56 |
<username></username> |
|
57 |
<notify /> |
|
58 |
</delete-user> |
|
59 |
||
60 |
<reload-config /> |
|
61 |
<restart-server /> |
|
62 |
||
63 |
<enable-plugin name="" /> |
|
64 |
<disable-plugin name="" /> |
|
65 |
</intents> |
|
66 |
</clientRequest> |
|
67 |
</virtualme> |
Up to file-list src/core/Request.java:
1 |
package core; |
|
2 |
||
3 |
import java.io.IOException; |
|
4 |
||
5 |
import java.io.InputStream; |
|
6 |
import java.io.OutputStream; |
|
7 |
||
8 |
import java.net.Socket; |
|
9 |
||
10 |
||
11 |
||
12 |
public class Request extends Thread { |
|
13 |
protected Socket s; |
|
14 |
||
15 |
public Request(Socket s, ThreadGroup tg) throws IOException { |
|
16 |
super(tg, s.getInetAddress().getHostAddress() + ':' + s.getPort()); |
|
17 |
||
18 |
this.s = s; |
|
19 |
String data = getXMLRequest(); |
|
20 |
} |
|
21 |
||
22 |
public String getXMLRequest() throws IOException { |
|
23 |
InputStream is = s.getInputStream(); |
|
24 |
||
25 |
String data = ""; |
|
26 |
int n; |
|
27 |
||
28 |
while((n = is.read()) != -1) { |
|
29 |
data += (char) n; |
|
30 |
} |
|
31 |
||
32 |
return ""; |
|
33 |
} |
|
34 |
} |
Up to file-list src/core/ServerProcess.java:
1 |
package core; |
|
2 |
||
3 |
import java.io.IOException; |
|
4 |
import java.net.ServerSocket; |
|
5 |
||
6 |
public class ServerProcess { |
|
7 |
public final int PORT = 31337; |
|
8 |
||
9 |
protected boolean run = true; // Semaphor! |
|
10 |
||
11 |
||
12 |
public ServerProcess() throws IOException { |
|
13 |
ServerSocket ss = new ServerSocket(PORT); |
|
14 |
||
15 |
ThreadGroup tg = new ThreadGroup("listeners"); |
|
16 |
tg.setMaxPriority(Thread.NORM_PRIORITY - 1); |
|
17 |
||
18 |
while(run) { |
|
19 |
Request rq = new Request(ss.accept(), tg); |
|
20 |
} |
|
21 |
} |
|
22 |
||
23 |
public void restart() { |
|
24 |
||
25 |
} |
|
26 |
} |
