15.07.2011, 08:50
(
Последний раз редактировалось Faab234; 15.07.2011 в 14:18.
)
A while ago I wrote a library for the SAMP Query mechanism in Java. This library was using the Apache MINA API.
Yesterday, I wrote a library for the SAMP Query mechanism using the jBoss Netty API. JSA-MP only supports the INFO opcode. Other opcodes will be released in the next releases.
https://github.com/FabianM/JSA-MP
Server Info Example:
Server rules example:
Client list example:
Detailed player info example:
Yesterday, I wrote a library for the SAMP Query mechanism using the jBoss Netty API. JSA-MP only supports the INFO opcode. Other opcodes will be released in the next releases.
https://github.com/FabianM/JSA-MP
Server Info Example:
PHP код:
package org.faabtech.jsamp;
import org.faabtech.jsamp.SAMPRequest.Opcode;
import org.faabtech.jsamp.data.DataProvider;
import org.faabtech.jsamp.data.impl.InfoDataProvider;
import org.faabtech.jsamp.event.SAMPResponseListener;
import org.faabtech.jsamp.net.Client;
/**
* Example class.
* @author Fabian M.
*/
public class Example {
public static void main(String[] args) {
SAMPRequest request = new SAMPRequest(new Client("188.165.206.114", 7777), Opcode.INFO);
request.send(new SAMPResponseListener() {
@Override
public void messageReceived(DataProvider dataProvider) {
InfoDataProvider info = (InfoDataProvider) dataProvider;
System.out.println(info.getPlayers());
}
});
}
}
PHP код:
package org.faabtech.jsamp;
import org.faabtech.jsamp.SAMPRequest.Opcode;
import org.faabtech.jsamp.data.DataProvider;
import org.faabtech.jsamp.data.impl.InfoDataProvider;
import org.faabtech.jsamp.data.impl.RuleDataProvider;
import org.faabtech.jsamp.event.SAMPResponseListener;
import org.faabtech.jsamp.net.Client;
import org.faabtech.jsamp.server.Rule;
/**
* Example class.
*
* @author Fabian M.
*/
public class Example {
public static void main(String[] args) {
SAMPRequest request = new SAMPRequest(
new Client("188.165.252.63", 7852), Opcode.RULES);
request.send(new SAMPResponseListener() {
@Override
public void messageReceived(DataProvider dataProvider) {
RuleDataProvider ruleDataProvider = (RuleDataProvider) dataProvider;
for (Rule rule : ruleDataProvider.getRules()) {
System.out.println(rule.getName() + ": " + rule.getValue());
}
}
});
}
}
PHP код:
package org.faabtech.jsamp;
import org.faabtech.jsamp.SAMPRequest.Opcode;
import org.faabtech.jsamp.data.DataProvider;
import org.faabtech.jsamp.data.impl.ClientListDataProvider;
import org.faabtech.jsamp.event.SAMPResponseListener;
import org.faabtech.jsamp.net.Client;
import org.faabtech.jsamp.server.Player;
import org.faabtech.jsamp.server.Rule;
/**
* Example class.
*
* @author Fabian M.
*/
public class Example {
public static void main(String[] args) {
SAMPRequest request = new SAMPRequest(
new Client("188.165.252.63", 7852), Opcode.CLIENT_LIST);
request.send(new SAMPResponseListener() {
@Override
public void messageReceived(DataProvider dataProvider) {
ClientListDataProvider clientListDataProvider = (ClientListDataProvider) dataProvider;
for (Player player : clientListDataProvider.getPlayers()) {
System.out.println(player.getUsername() + ": " + player.getScore());
}
}
});
}
}
PHP код:
package org.faabtech.jsamp;
import org.faabtech.jsamp.SAMPRequest.Opcode;
import org.faabtech.jsamp.data.DataProvider;
import org.faabtech.jsamp.data.impl.PlayerDataProvider;
import org.faabtech.jsamp.event.SAMPResponseListener;
import org.faabtech.jsamp.net.Client;
import org.faabtech.jsamp.server.Player;
/**
* Example class.
*
* @author Fabian M.
*/
public class Example {
public static void main(String[] args) {
SAMPRequest request = new SAMPRequest(
new Client("188.165.252.63", 7852), Opcode.DETAILED_PLAYER_INFO);
request.send(new SAMPResponseListener() {
@Override
public void messageReceived(DataProvider dataProvider) {
PlayerDataProvider playerDataProvider = (PlayerDataProvider) dataProvider;
for (Player player : playerDataProvider.getPlayers()) {
System.out.println(player.getPlayerId() + ": " + player.getPing());
}
}
});
}
}