mirror of
https://github.com/fluencelabs/fluid
synced 2025-06-17 23:31:20 +00:00
msg => message
This commit is contained in:
@ -11,7 +11,7 @@ export function handler(input: string): string {
|
||||
|
||||
if (request.action == Action.Post) {
|
||||
let post = request as PostRequest;
|
||||
addMessage(post.msg, post.username);
|
||||
addMessage(post.message, post.username);
|
||||
let count = getPostsCount();
|
||||
|
||||
let response = new PostResponse(count);
|
||||
|
@ -3,7 +3,7 @@ import {log} from "../node_modules/assemblyscript-sdk/assembly/logger";
|
||||
export function createScheme(): void {
|
||||
log("create scheme");
|
||||
}
|
||||
export function addMessage(msg: string, username: string): void {
|
||||
export function addMessage(message: string, username: string): void {
|
||||
log("add message");
|
||||
}
|
||||
export function getMessages(username: string | null): string {
|
||||
|
@ -13,12 +13,12 @@ export abstract class Request {
|
||||
|
||||
export class PostRequest extends Request {
|
||||
|
||||
public readonly msg: string;
|
||||
public readonly message: string;
|
||||
public readonly username: string;
|
||||
|
||||
constructor(msg: string, username: string) {
|
||||
constructor(message: string, username: string) {
|
||||
super();
|
||||
this.msg = msg;
|
||||
this.message = message;
|
||||
this.username = username;
|
||||
this.action = Action.Post;
|
||||
}
|
||||
@ -60,7 +60,7 @@ export function decode(input: string): Request {
|
||||
if (action == "Fetch") {
|
||||
request = new FetchRequest(jsonHandler.filter_handle);
|
||||
} else if (action == "Post") {
|
||||
request = new PostRequest(jsonHandler.msg, jsonHandler.username)
|
||||
request = new PostRequest(jsonHandler.message, jsonHandler.username)
|
||||
} else {
|
||||
request = new UnknownRequest()
|
||||
}
|
||||
@ -71,7 +71,7 @@ export function decode(input: string): Request {
|
||||
class RequestJSONEventsHandler extends JSONHandler {
|
||||
|
||||
public action: string;
|
||||
public msg: string;
|
||||
public message: string;
|
||||
public username: string;
|
||||
public filter_handle: string | null;
|
||||
|
||||
@ -79,8 +79,8 @@ class RequestJSONEventsHandler extends JSONHandler {
|
||||
|
||||
if (name == "action") {
|
||||
this.action = value;
|
||||
} else if (name == "msg") {
|
||||
this.msg = value;
|
||||
} else if (name == "message") {
|
||||
this.message = value;
|
||||
} else if (name == "username") {
|
||||
this.username = value;
|
||||
this.filter_handle = value;
|
||||
|
@ -8,11 +8,11 @@ export abstract class Response {
|
||||
}
|
||||
|
||||
export class Message {
|
||||
msg: string;
|
||||
message: string;
|
||||
username: string;
|
||||
|
||||
constructor(msg: string, username: string) {
|
||||
this.msg = msg;
|
||||
constructor(message: string, username: string) {
|
||||
this.message = message;
|
||||
this.username = username;
|
||||
}
|
||||
}
|
||||
@ -26,7 +26,7 @@ export class UnknownResponse extends Response {
|
||||
let encoder = new JSONEncoder();
|
||||
encoder.pushObject(null);
|
||||
encoder.setString("action", "Unknown");
|
||||
encoder.setString("msg", "cannot username request");
|
||||
encoder.setString("message", "cannot username request");
|
||||
encoder.popObject();
|
||||
|
||||
return encoder.toString();
|
||||
@ -34,17 +34,16 @@ export class UnknownResponse extends Response {
|
||||
}
|
||||
|
||||
export class PostResponse extends Response {
|
||||
msgCount: u32;
|
||||
constructor(msgCount: u32) {
|
||||
count: u32;
|
||||
constructor(count: u32) {
|
||||
super();
|
||||
this.msgCount = msgCount;
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
serialize(): string {
|
||||
let encoder = new JSONEncoder();
|
||||
encoder.pushObject(null);
|
||||
encoder.setString("action", "Post");
|
||||
encoder.setInteger("count", this.msgCount);
|
||||
encoder.setInteger("count", this.count);
|
||||
encoder.popObject();
|
||||
|
||||
return encoder.toString();
|
||||
@ -62,12 +61,11 @@ export class FetchResponse extends Response {
|
||||
serialize(): string {
|
||||
let encoder = new JSONEncoder();
|
||||
encoder.pushObject(null);
|
||||
encoder.setString("action", "Fetch");
|
||||
encoder.pushArray("posts");
|
||||
for (let i = 0; i < this.posts.length; i++) {
|
||||
let twit = this.posts[i];
|
||||
encoder.pushObject(null);
|
||||
encoder.setString("msg", twit.msg);
|
||||
encoder.setString("message", twit.message);
|
||||
encoder.setString("username", twit.username);
|
||||
encoder.popObject();
|
||||
}
|
||||
|
Reference in New Issue
Block a user