Skip to content

Commit

Permalink
Merge pull request #57 from RoboCup-MSL/private_welcome_message
Browse files Browse the repository at this point in the history
Private welcome message
  • Loading branch information
Sirkle23 authored Apr 19, 2022
2 parents f16f9ed + 80ada49 commit 10e27ea
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 388 deletions.
18 changes: 14 additions & 4 deletions mslrb2015/Comms.pde
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static void clientValidation(MyServer whichServer, Client whichClient) {
}


public static void send_to_basestation(String c, String teamIP, int robotID){
public static void send_to_basestation(String c, String teamIP, int robotID, Client client){

JSONObject jsonObject = new JSONObject();
jsonObject.put("command", c);
Expand All @@ -51,7 +51,11 @@ public static void send_to_basestation(String c, String teamIP, int robotID){
}
String send = jsonObject.toString() + "\0";
System.out.println(send);
BaseStationServer.write(send);
if (client == null) {
BaseStationServer.write(send);
} else {
BaseStationServer.write(send, client);
}
}

public static void event_message_v2(ButtonsEnum btn, boolean on)
Expand Down Expand Up @@ -80,8 +84,9 @@ public static void event_message_v2(ButtonsEnum btn, boolean on)
msg > string with description message to send to scoreclients @mbc (check if needed)
t > id of the team. If null, message is to both teams
robotID > ID number of the target robot. (-1) means no robot
client > Selectively send event to one client, null is sending to all client teams
*/
public static void send_event_v2(String cmd, String msg, Team t, int robotID)
public static void send_event_v2(String cmd, String msg, Team t, int robotID, Client client)
{
String teamIP, teamName;

Expand All @@ -93,7 +98,7 @@ public static void send_event_v2(String cmd, String msg, Team t, int robotID)
teamIP = t.multicastIP;
teamName = t.team;
}
send_to_basestation(cmd, teamIP, robotID); //send to basestation
send_to_basestation(cmd, teamIP, robotID, client); //send to basestation
scoreClients.update_tEvent(cmd, msg, teamName, robotID); //send to referee client
//mslRemote.update_tEvent(cmd, msg, t); //remote command

Expand All @@ -103,6 +108,11 @@ public static void send_event_v2(String cmd, String msg, Team t, int robotID)

}

public static void send_event_v2(String cmd, String msg, Team t, int robotID)
{
send_event_v2(cmd, msg, t, robotID, null);
}

public static boolean setteamfromip(String s) {
String clientipstr="127.0.0.*";
String[] iptokens;
Expand Down
6 changes: 6 additions & 0 deletions mslrb2015/MyServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -407,4 +407,10 @@ public void write(String data) {
}
}
}

public void write(String data, Client client) {
if (client.active()) {
client.write(data);
}
}
}
Loading

0 comments on commit 10e27ea

Please sign in to comment.