tenebrous-sheets/static/scripts/src/index.ts

27 lines
900 B
TypeScript

import * as api from "./api";
import { grpc } from "@improbable-eng/grpc-web";
import { CofdApi } from "../_proto/cofd_api_pb_service";
import { UpdateSkillValueRequest } from "../_proto/cofd_api_pb";
import { CofdSheet } from "../_proto/cofd_pb";
console.log(api.updateSkillValue);
let x = new UpdateSkillValueRequest();
x.setCharacterId(1);
x.setCharacterUsername("guy");
console.log("hello", x);
grpc.invoke(CofdApi.UpdateSkillValue, {
request: x,
host: window.location.protocol + "//" + window.location.hostname + ":8080",
onMessage: (message: CofdSheet.Skill) => {
console.log("got skill: ", message.toObject());
},
onEnd: (code: grpc.Code, msg: string | undefined, trailers: grpc.Metadata) => {
if (code == grpc.Code.OK) {
console.log("all ok")
} else {
console.log("hit an error", code, msg, trailers);
}
}
});