mirror of
https://github.com/Leahnaya/UBFunkeysServer.git
synced 2026-04-22 00:17:32 -05:00
Fix u_cph | Modify ArkOneSender
- Needs testing to verify fixed and if Sender works
This commit is contained in:
parent
f1b11c0247
commit
e40677bfdd
|
|
@ -81,7 +81,7 @@ public class ArkOneController implements TcpHandler {
|
|||
responses.add(userPlugin.ChangeChatStatus(commandInfo, connection));
|
||||
break;
|
||||
case "u_cph":
|
||||
responses.add(userPlugin.ChangePhoneStatus(commandInfo));
|
||||
responses.add(userPlugin.ChangePhoneStatus(commandInfo, connection));
|
||||
break;
|
||||
case "p":
|
||||
responses.add(userPlugin.Ping());
|
||||
|
|
|
|||
|
|
@ -62,25 +62,21 @@ public class ArkOneSender {
|
|||
}
|
||||
|
||||
public void SendToUser(UUID clientId, String message) {
|
||||
Connection connection = null;
|
||||
|
||||
for (Connection conn : server.getConnections()) {
|
||||
if (conn.getClientIdentifier() == clientId) {
|
||||
connection = conn;
|
||||
}
|
||||
}
|
||||
try {
|
||||
// Append a 0x00 to the end of the response
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
outputStream.write(message.getBytes());
|
||||
outputStream.write((byte)0x00);
|
||||
|
||||
if (connection != null) {
|
||||
try {
|
||||
// Append a 0x00 to the end of the response
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
outputStream.write(message.getBytes());
|
||||
outputStream.write((byte)0x00);
|
||||
conn.send(outputStream.toByteArray());
|
||||
|
||||
connection.send(outputStream.toByteArray());
|
||||
} catch (IOException e) {
|
||||
System.out.println("[ArkOne][ERROR] Failed to send message to user [" + clientId + "]: " + message);
|
||||
e.printStackTrace();
|
||||
return;
|
||||
} catch (IOException e) {
|
||||
System.out.println("[ArkOne][ERROR] Failed to send message to user [" + clientId + "]: " + message);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -144,6 +144,7 @@ public class UserPlugin {
|
|||
public String ChangeChatStatus(Element element, Connection connection) throws ParserConfigurationException, TransformerException {
|
||||
User user = server.getConnectedUsers().get(connection.getClientIdentifier());
|
||||
|
||||
// Update the chat status
|
||||
user.setChatStatus(Integer.valueOf(element.getAttribute("s")));
|
||||
userService.updateUserOnServer(connection, user);
|
||||
|
||||
|
|
@ -162,14 +163,12 @@ public class UserPlugin {
|
|||
return ArkOneParser.RemoveXMLTag(doc);
|
||||
}
|
||||
|
||||
public String ChangePhoneStatus(Element element) throws ParserConfigurationException, TransformerException {
|
||||
//TODO: VERIFY THE ATTRIBUTE NAME
|
||||
User user = userService.findByUUID(Integer.valueOf(element.getAttribute("id"))).orElse(null);
|
||||
public String ChangePhoneStatus(Element element, Connection connection) throws ParserConfigurationException, TransformerException {
|
||||
User user = server.getConnectedUsers().get(connection.getClientIdentifier());
|
||||
|
||||
//TODO: VERIFY THE ATTRIBUTE NAME
|
||||
// Update that user's chat status
|
||||
// Update the phone status
|
||||
user.setPhoneStatus(Integer.valueOf(element.getAttribute("ph")));
|
||||
userService.save(user);
|
||||
userService.updateUserOnServer(connection, user);
|
||||
|
||||
// Build the response
|
||||
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user