Skip to content

Commit

Permalink
TMP
Browse files Browse the repository at this point in the history
  • Loading branch information
sgnsajgon committed Nov 17, 2023
1 parent 0a9f0af commit 0490496
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 51 deletions.
2 changes: 1 addition & 1 deletion client/src/main/java/org/wot/tak/client/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ private void sendFilesFromDirectoryUsingConnector(TAKServerConnector connector,
for (File file : files) {
var xml = Files.readString(file.toPath());
var event = EventMarshalling.fromBytes(xml.getBytes());
connector.send(event);
// connector.send(event);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
public class SSLConnector extends StreamingTcpConnector {

public SSLConnector(String url, String port, SocketFactory sFactory) {
super(url, port, sFactory, true);
super(url, port, sFactory, false);
}

public SSLConnector(String url, String port, SocketFactory sFactory, boolean negotiateProtobufProtocol) {
Expand Down
2 changes: 1 addition & 1 deletion connection/src/main/resources/protocol/xml/wot/Detail.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@
<xs:complexType name="remarks" mixed="true">
<xs:annotation>
<xs:documentation>Provides a place to annotate CoT with free text information. e.g. comments from other
users about the current COT. Used also fro the geoChat.
users about the current COT. Used also from the geoChat.
</xs:documentation>
<xs:documentation>the xml body of this class is used to transport the chat message</xs:documentation>
</xs:annotation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<xs:annotation>
<xs:documentation>
A system-specific flowtag identifier associated with the encapsulating CoT object.
The attribute value should be an xs:dateTime value.
The attribute value should be a xs:dateTime value.
</xs:documentation>
</xs:annotation>
</xs:anyAttribute>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void Connector_can_send_and_and_receive_messages_using_XML_protocol() throws Exc
var alphaChatMessage = MessageFormat.format("Test message {0}", UUID.randomUUID());
var bravoChatMessage = MessageFormat.format("Test message {0}", UUID.randomUUID());

var alphaMessage = ClientXmlMessage.announcement(alphaUid, alphaCallsign, alphaChatMessage);
var alphaMessage = ClientXmlMessage.announcement(alphaUid, alphaCallsign);
var bravoMessage = ClientXmlMessage.chat(bravoUid, alphaCallsign, bravoChatMessage);

var alphaReceivedMessages = new CopyOnWriteArrayList<Event>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.GregorianCalendar;
import java.util.Random;
import java.util.TimeZone;
import java.util.UUID;

public final class ClientProtobufMessage {

private static final double LATITUDE = 27.85009;
private static final double LONGITUDE = -81.063847;

private ClientProtobufMessage() {
}

Expand All @@ -51,8 +53,8 @@ public static Takmessage.TakMessage announcement(UUID uid, String callsign)
.setStartTime(now)
.setStaleTime(now + 5 * 60 * 1000)
.setHow("h-g-i-g-o")
.setLat(27.85009)
.setLon(-81.063847)
.setLat(LATITUDE)
.setLon(LONGITUDE)
.setHae(9999999.0)
.setCe(9999999.0)
.setLe(9999999.0)
Expand Down Expand Up @@ -107,8 +109,6 @@ public static Takmessage.TakMessage chat(UUID uid, String callsign, String chatM
throws DatatypeConfigurationException, XMLStreamException, JAXBException {

var now = System.currentTimeMillis();
var latitude = 52.2312 + (0.5 - new Random().nextFloat()) / 10;
var longitude = 21.016 + (0.5 - new Random().nextFloat()) / 10;

var message = Takmessage.TakMessage.newBuilder()
.setCotEvent(Cotevent.CotEvent.newBuilder()
Expand All @@ -119,8 +119,8 @@ public static Takmessage.TakMessage chat(UUID uid, String callsign, String chatM
.setStartTime(now)
.setStaleTime(now + 5 * 60 * 1000)
.setHow("h-g-i-g-o")
.setLat(latitude)
.setLon(longitude)
.setLat(LATITUDE)
.setLon(LONGITUDE)
.setHae(9999999.0)
.setCe(9999999.0)
.setLe(9999999.0)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,27 @@
package org.wot.tak.connection.messages;

import org.wot.tak.connection.protocol.xml.Contact;
import org.wot.tak.connection.protocol.xml.Detail;
import org.wot.tak.connection.protocol.xml.Event;
import org.wot.tak.connection.protocol.xml.Group;
import org.wot.tak.connection.protocol.xml.Point;
import org.wot.tak.connection.protocol.xml.Precisionlocation;
import org.wot.tak.connection.protocol.xml.Remarks;
import org.wot.tak.connection.protocol.xml.Status;
import org.wot.tak.connection.protocol.xml.Takv;
import org.wot.tak.connection.protocol.xml.Track;
import org.wot.tak.connection.protocol.xml.Uid;
import org.wot.tak.connection.protocol.xml.Usericon;
import org.wot.tak.connection.protocol.xml.*;

import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.text.MessageFormat;
import java.util.GregorianCalendar;
import java.util.Random;
import java.util.TimeZone;
import java.util.UUID;

public final class ClientXmlMessage {

private static final double LATITUDE = 40.2100278338638;
private static final double LONGITUDE = -92.6243997054913;
private static final double HAE = 246.411508368538;

private ClientXmlMessage() {
}

public static Event announcement(UUID uuid, String callsign)
throws DatatypeConfigurationException {

var now = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
var xmlNow = DatatypeFactory.newInstance().newXMLGregorianCalendar(now);
var stale = xmlNow.toGregorianCalendar();
Expand All @@ -38,7 +30,7 @@ public static Event announcement(UUID uuid, String callsign)

var event = new Event();
event.setAccess("Undefined");
event.setHow("h-g-i-g-o");
event.setHow("h-e");
event.setStale(xmlStale);
event.setStart(xmlNow);
event.setTime(xmlNow);
Expand All @@ -49,10 +41,10 @@ public static Event announcement(UUID uuid, String callsign)
var point = new Point();
event.setPoint(point);
point.setCe(BigDecimal.valueOf(9999999.0));
point.setHae(BigDecimal.valueOf(9999999.0));
point.setLat(BigDecimal.valueOf(27.85009));
point.setHae(BigDecimal.valueOf(HAE));
point.setLat(BigDecimal.valueOf(LATITUDE));
point.setLe(BigDecimal.valueOf(9999999.0));
point.setLon(BigDecimal.valueOf(-81.063847));
point.setLon(BigDecimal.valueOf(LONGITUDE));

var detail = new Detail();
event.setDetail(detail);
Expand All @@ -65,9 +57,9 @@ public static Event announcement(UUID uuid, String callsign)
var contact = new Contact();
detail.setContact(contact);
contact.setCallsign(callsign);
contact.setEndpoint("1:sctp");
contact.setEndpoint("*:-1:stcp");

var status = new Status();
var status = new Status();
detail.setStatus(status);
status.setBattery(BigInteger.valueOf(98));

Expand Down Expand Up @@ -107,40 +99,64 @@ public static Event chat(UUID id, String callsign, String chatMessage)
var xmlStale = DatatypeFactory.newInstance().newXMLGregorianCalendar(stale);
stale.add(GregorianCalendar.MINUTE, 5);

var latitude = 52.2312 + (0.5 - new Random().nextFloat()) / 10;
var longitude = 21.016 + (0.5 - new Random().nextFloat()) / 10;
var chatroomName = "All Chat Rooms";
var messageId = UUID.randomUUID().toString();
var geoChatId = MessageFormat.format("GeoChat.{0}.{1}.{2}", id, chatroomName, messageId);
var remarkSource = "BAO.F.WinTAK." + id;

var event = new Event();
event.setVersion(BigDecimal.valueOf(2));
event.setUid(id.toString());
event.setType("a-n-G");
event.setTime(xmlNow);
event.setStart(xmlNow);
event.setStale(xmlStale);
event.setAccess("Undefined");
event.setHow("h-g-i-g-o");
event.setStale(xmlStale);
event.setStart(xmlNow);
event.setTime(xmlNow);
event.setType("b-t-f");
event.setUid(geoChatId);
event.setVersion(BigDecimal.valueOf(2));

var point = new Point();
point.setLat(BigDecimal.valueOf(latitude));
point.setLon(BigDecimal.valueOf(longitude));
point.setHae(BigDecimal.valueOf(9999999.0));
event.setPoint(point);
point.setCe(BigDecimal.valueOf(9999999.0));
point.setHae(BigDecimal.valueOf(HAE));
point.setLat(BigDecimal.valueOf(LATITUDE));
point.setLe(BigDecimal.valueOf(9999999.0));
event.setPoint(point);
point.setLon(BigDecimal.valueOf(LONGITUDE));

var detail = new Detail();
event.setDetail(detail);

var chat = new Chat();
detail.setChat(chat);
chat.setChatroom(chatroomName);
chat.setGroupOwner(false);
chat.setId(chatroomName);
chat.setMessageId(messageId);
chat.setSenderCallsign(callsign);

var chatgrp = new Chatgrp();
chat.setChatgrp(chatgrp);
chatgrp.setId(chatroomName);
chatgrp.setUid0(id.toString());
chatgrp.setUid1(chatroomName);

var link = new Link();
detail.setLink(link);
link.setRelation("p-p");
link.setType("a-f-G-U-C-I");
link.setUid(id.toString());

var remarks = new Remarks();
remarks.setSource("Automated-Integration-Test" + callsign);
remarks.setSourceID("Automated-Integration-Test" + callsign);
detail.setRemarks(remarks);
remarks.setSource(remarkSource);
remarks.setSourceID(id.toString());
remarks.setTime(xmlNow);
remarks.setTo("All Chat Rooms");
remarks.setTo(chatroomName);
remarks.setContent(chatMessage);
detail.setRemarks(remarks);

var contact = new Contact();
contact.setCallsign(callsign);
detail.setContact(contact);
var flowTags = new FlowTags();
detail.setFlowTags(flowTags);
flowTags.getOtherAttributes().put(
new javax.xml.namespace.QName("TAK-Server-" + UUID.randomUUID()), xmlNow.toString());

return event;
}
Expand Down

0 comments on commit 0490496

Please sign in to comment.