Update README

This commit is contained in:
Moxie Marlinspike 2015-03-05 10:50:49 -08:00
parent fa4e7c5f0b
commit cb4eb3c202

View File

@ -46,11 +46,10 @@ TextSecureMessageSender messageSender = new TextSecureMessageSender(URL, TRUST_S
localRecipientId, new MyAxolotlStore(), localRecipientId, new MyAxolotlStore(),
Optional.absent()); Optional.absent());
long recipientId = getRecipientIdFor("+14159998888"); messageSender.sendMessage(new TextSecureAddress("+14159998888"),
TextSecureAddress destination = new TextSecureAddress(recipientId, "+14159998888", null); TextSecureMessage.newBuilder()
TextSecureMessage message = new TextSecureMessage(System.currentTimeMillis(), "Hello, world!"); .withBody("Hello, world!")
.build());
messageSender.sendMessage(destination, message);
````` `````
## Sending media messages ## Sending media messages
@ -60,15 +59,19 @@ TextSecureMessageSender messageSender = new TextSecureMessageSender(URL, TRUST_S
localRecipientId, new MyAxolotlStore(), localRecipientId, new MyAxolotlStore(),
Optional.absent()); Optional.absent());
long recipientId = getRecipientIdFor("+14159998888");
TextSecureAddress destination = new TextSecureAddress(recipientId, "+14159998888", null);
File myAttachment = new File("/path/to/my.attachment"); File myAttachment = new File("/path/to/my.attachment");
FileInputStream attachmentStream = new FileInputStream(myAttachment); FileInputStream attachmentStream = new FileInputStream(myAttachment);
TextSecureAttachment attachment = new TextSecureAttachmentStream(attachmentStream, "image/png", myAttachment.size()); TextSecureAttachment attachment = TextSecureAttachment.newStreamBuilder()
TextSecureMessage message = new TextSecureMessage(System.currentTimeMillis(), attachment, "Hello, world!"); .withStream(attachmentStream)
.withContentType("image/png")
.withLength(myAttachment.size())
.build();
messageSender.sendMessage(destination, message); messageSender.sendMessage(new TextSecureAddress("+14159998888"),
TextSecureMessage.newBuilder()
.withBody("An attachment!")
.withAttachment(attachment)
.build());
````` `````
@ -83,9 +86,7 @@ try {
while (listeningForMessages) { while (listeningForMessages) {
TextSecureEnvelope envelope = messagePipe.read(timeout, timeoutTimeUnit); TextSecureEnvelope envelope = messagePipe.read(timeout, timeoutTimeUnit);
TextSecureCipher cipher = new TextSecureCipher(new MyAxolotlStore(), TextSecureCipher cipher = new TextSecureCipher(new MyAxolotlStore());
getRecipientIdFor(envelope.getSource()),
envelope.getSourceDevice());
TextSecureMessage message = cipher.decrypt(envelope); TextSecureMessage message = cipher.decrypt(envelope);
System.out.println("Received message: " + message.getBody().get()); System.out.println("Received message: " + message.getBody().get());