mirror of
https://github.com/oxen-io/session-android.git
synced 2025-04-30 18:00:47 +00:00
Update README
This commit is contained in:
parent
fa4e7c5f0b
commit
cb4eb3c202
29
README.md
29
README.md
@ -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());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user