mirror of
https://github.com/fluencelabs/fluid
synced 2025-04-24 14:22:18 +00:00
fix AS, add console doc
This commit is contained in:
parent
8f8fd80c61
commit
491a4aeaae
@ -10,7 +10,7 @@ export function addMessage(message: string, username: string): void {
|
||||
query(request);
|
||||
}
|
||||
|
||||
export function getMessages(username: string | null, offset: u32, count: u32): string {
|
||||
export function getMessages(username: string | null, offset: i64, count: i64): string {
|
||||
let limitClause = ` LIMIT ` + count.toString() + ` OFFSET ` + offset.toString() + ` `;
|
||||
if (username) {
|
||||
let whereClause = ` WHERE username = "` + username + `" `;
|
||||
|
@ -26,10 +26,10 @@ export class PostRequest extends Request {
|
||||
|
||||
export class FetchRequest extends Request {
|
||||
public readonly username: string | null;
|
||||
public readonly offset: u32;
|
||||
public readonly count: u32;
|
||||
public readonly offset: i64;
|
||||
public readonly count: i64;
|
||||
|
||||
constructor(username: string | null, offset: u32, count: u32) {
|
||||
constructor(username: string | null, offset: i64, count: i64) {
|
||||
super();
|
||||
this.action = Action.Fetch;
|
||||
this.username = username;
|
||||
@ -78,13 +78,18 @@ class RequestJSONEventsHandler extends JSONHandler {
|
||||
public message: string;
|
||||
public username: string;
|
||||
public filter_handle: string | null;
|
||||
public offset: u32;
|
||||
public count: u32;
|
||||
public offset: i64 = 0;
|
||||
public count: i64 = 100;
|
||||
|
||||
setInteger(name: string, value: i64): void {
|
||||
if (name == "offset") {
|
||||
this.offset = value;
|
||||
} else if (name == "count") {
|
||||
this.count = value;
|
||||
}
|
||||
}
|
||||
|
||||
setString(name: string, value: string): void {
|
||||
this.offset = 0;
|
||||
this.count = 100;
|
||||
|
||||
if (name == "action") {
|
||||
this.action = value;
|
||||
} else if (name == "message") {
|
||||
@ -92,11 +97,6 @@ class RequestJSONEventsHandler extends JSONHandler {
|
||||
} else if (name == "username") {
|
||||
this.username = value;
|
||||
this.filter_handle = value;
|
||||
} else if (name == "offset") {
|
||||
this.offset = U32.parseInt(value);
|
||||
} else if (name == "count") {
|
||||
this.count = U32.parseInt(value);
|
||||
}
|
||||
// json scheme is not strict, so we won't throw an error on excess fields
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,28 @@ import ConnectionToggle from "./ConnectionToggle";
|
||||
|
||||
class App extends Component {
|
||||
|
||||
componentDidMount() {
|
||||
console.log(`
|
||||
|
||||
Hello, Fluencer!
|
||||
Thank you for trying Fluence out!
|
||||
You can find docs at https://fluence.dev
|
||||
Check out http://dash.fluence.network to deploy your own SQL DB instance
|
||||
Check out https://github.com/fluencelabs/tutorials for more Fluence examples
|
||||
If you have any questions, feel free to join our Discord https://fluence.chat :)
|
||||
|
||||
You can send requests to Fluence network straight from console:
|
||||
|
||||
// send the message and don't wait for a response
|
||||
fluenceSession.requestAsync('{"action": "Post", "message": "Hello, Fluence!", "username": "fluencer"}')
|
||||
|
||||
// get the last message, decode response as a string and print it in the console
|
||||
fluenceSession.request('{"action": "Fetch", "offset": 0, "limit": 1}').then((r) => r.asString()).then(console.log)
|
||||
|
||||
|
||||
`)
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Router>
|
||||
|
Loading…
x
Reference in New Issue
Block a user