mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-06 05:23:56 -07:00
Add some sessions (#5052)
* Add AccountEdit * Add PasswordChange * Cleanup * Add SessionService.accountImage * Add SessionService.message * Add SessionService.getUserInfo * Lint
This commit is contained in:
parent
34d70980e8
commit
e2ab8db958
8 changed files with 190 additions and 0 deletions
30
webclient/src/websocket/commands/session/accountImage.ts
Normal file
30
webclient/src/websocket/commands/session/accountImage.ts
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import webClient from '../../WebClient';
|
||||
import { SessionPersistence } from '../../persistence';
|
||||
import { common } from 'protobufjs';
|
||||
import IBytesValue = common.IBytesValue;
|
||||
|
||||
export function accountImage(image: IBytesValue): void {
|
||||
const command = webClient.protobuf.controller.Command_AccountImage.create({ image });
|
||||
|
||||
const sc = webClient.protobuf.controller.SessionCommand.create({
|
||||
'.Command_AccountImage.ext': command
|
||||
});
|
||||
|
||||
webClient.protobuf.sendSessionCommand(sc, raw => {
|
||||
const { responseCode } = raw;
|
||||
|
||||
switch (responseCode) {
|
||||
case webClient.protobuf.controller.Response.ResponseCode.RespOk:
|
||||
SessionPersistence.accountImageChanged();
|
||||
break;
|
||||
case webClient.protobuf.controller.Response.ResponseCode.RespFunctionNotAllowed:
|
||||
console.log('Not allowed');
|
||||
break;
|
||||
case webClient.protobuf.controller.Response.ResponseCode.RespWrongPassword:
|
||||
console.log('Wrong password');
|
||||
break;
|
||||
default:
|
||||
console.log('Failed to update information');
|
||||
}
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue