From c15f3be0e3e262ce87ac0be4289299f5b92e0d05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Cidre?= Date: Fri, 13 Apr 2018 12:35:46 +0200 Subject: [PATCH] [#IDEA-146] Describe milestone 2 --- .../146-status-go-sdk/Milestone1_BasicSDK.md | 16 ++++-- .../Milestone2_PublicChannels.md | 50 +++++++++++++++++++ ideas/146-status-go-sdk/README.md | 5 +- .../howto_Sniffing_app_messages.md | 21 ++++++++ 4 files changed, 86 insertions(+), 6 deletions(-) create mode 100644 ideas/146-status-go-sdk/Milestone2_PublicChannels.md create mode 100644 ideas/146-status-go-sdk/howto_Sniffing_app_messages.md diff --git a/ideas/146-status-go-sdk/Milestone1_BasicSDK.md b/ideas/146-status-go-sdk/Milestone1_BasicSDK.md index fc9ed93..9f28cb2 100644 --- a/ideas/146-status-go-sdk/Milestone1_BasicSDK.md +++ b/ideas/146-status-go-sdk/Milestone1_BasicSDK.md @@ -1,6 +1,6 @@ -## Milestone 1: Basic SDK +## Milestone 1: Status messaging basic interaction -// TODO its still not clear how username works on the new protocol, it may change the methods using it, as it's not used atm. +** * TODO its still not clear how username works on the new protocol, it may change the methods using it, as it's not used atm. ** ### Setup a new connection @@ -46,7 +46,7 @@ if err := conn.SignupOrLogin("username", "password"); err != nil { `SignupOrLogin` method is provided so you can sign up as a specific user ``` -if err := conn.Login("username", "password"); err != nil { +if err := conn.SignupOrLogin("username", "password"); err != nil { panic(err) } ``` @@ -54,7 +54,15 @@ if err := conn.Login("username", "password"); err != nil { ### Ability to login as a specific account +`Login` method provides an interface to log in + +``` +if err := conn.Login("username", "password"); err != nil { + panic(err) +} +``` +### Documented API for basic sdk interaction -### Ability to log out. +This document can be adapted as a documentation for basic sdk interaction diff --git a/ideas/146-status-go-sdk/Milestone2_PublicChannels.md b/ideas/146-status-go-sdk/Milestone2_PublicChannels.md new file mode 100644 index 0000000..66cc08f --- /dev/null +++ b/ideas/146-status-go-sdk/Milestone2_PublicChannels.md @@ -0,0 +1,50 @@ +## Milestone 2: Public channels interaction + +Public channels interaction is about how the developer will be interacting with public channels. + +### Ability to join public channels + +A new public channel will be joined using Join method: +``` +ch, err := conn.Join("my_channel") +if err != nil { + panic("Couldn't join my_channel") +} +``` + +### Ability to publish messages on public channels +You can use the Channel object to publish messages on it as follows: +``` +ch, _ := conn.Join("my_channel") +ch.Publish("Hello world") +``` + +### Ability to subscribe to public channels +Subscribing a channel means a script will be able to listen to any messages on a specific public channel. This can be achieved with Channel Subscribe method as follows: +``` +ch, _ := conn.Join("my_channel") +ch.Subscribe(func(m *sdk.Msg) { + log.Println("Message from ", m.From, " with body: ", m.Text) +} +``` + +### Ability to unsubscribe from a public channel +In order to unsubscribe from a specific public channel you just have to call Unsubscribe method. +``` +ch, _ := conn.Join("my_channel") +ch.Subscribe(func(m *sdk.Msg) { + if m.Text == "BYE!" { + ch.Unsubscribe() + } +} +``` + + +### Documented API for public channels interaction. + +This document can be adapted as a documentation for public channels interaction + + +### Working examples for public channel interaction. + +Actually [here](https://github.com/status-im/status-go/blob/sdk/sdk/examples/) you'll find an example of a "ping pong game". diff --git a/ideas/146-status-go-sdk/README.md b/ideas/146-status-go-sdk/README.md index 3d520de..e72e8cd 100644 --- a/ideas/146-status-go-sdk/README.md +++ b/ideas/146-status-go-sdk/README.md @@ -90,6 +90,7 @@ Description: - [Pre-existing issue](https://github.com/status-im/ideas/issues/131) - [New protocol spec](https://docs.google.com/document/d/1Qh2h07T_qepzEJ7IytmxwIdQAOsGHrvhXwZxuZtbwgc/edit#) - [transit-format](https://github.com/cognitect/transit-format) +- [Sniffing app messages](howto_Sniffing_app_messages.md) ### Blockers @@ -104,14 +105,14 @@ Testing Days required: TBD ## Success Metrics -#### [Milestone 1: Status messaging basic interaction](Milestone1_BasicSDK.md) +#### Milestone 1: [Status messaging basic interaction](Milestone1_BasicSDK.md) - [ ] Setup a new connection - [ ] Ability to close a specific connection - [ ] Ability to change connection configuration - [ ] Ability to sign up on the platform - [ ] Ability to login as a specific account -#### Milestone 2: Public channels interaction +#### Milestone 2: [Public channels interaction](Mileston2_PublicChannels.md) - [ ] Ability to join public channels - [ ] Ability to publish messages on public channels - [ ] Ability to subscribe to public channels diff --git a/ideas/146-status-go-sdk/howto_Sniffing_app_messages.md b/ideas/146-status-go-sdk/howto_Sniffing_app_messages.md new file mode 100644 index 0000000..ec3b2d5 --- /dev/null +++ b/ideas/146-status-go-sdk/howto_Sniffing_app_messages.md @@ -0,0 +1,21 @@ +## HOWTO : Sniffing app messages + +So one of the main points of this swarm is to interact with status app, to do that, we need to speak its same language. + +To do that the easiest way is to sniff messages sent by the app, to do this you can: + +1.- Clone status-react +2.- Add a log line on [StatusModule.java::sendWeb3Request method](https://github.com/status-im/status-react/blob/develop/modules/react-native-status/android/src/main/java/im/status/ethereum/module/StatusModule.java#L690) printing the payload like: + +``` +Thread thread = new Thread() { + @Override + public void run() { ++ Log.d("PAYLOAD", "PAYLOAD : " + payload); ++ + String res = Statusgo.CallRPC(payload); + callback.invoke(res); + } +``` +3.- [Deploy it to your devide/emulator](https://wiki.status.im/Building_Status) +4.- Connect to your emulator and check the logs `adb logcat|grep "PAYLOAD"`