import * as vscode from 'vscode'; import { MessageHandler } from './messageHandler'; import { regInMessage, regOutMessage } from '../util/reg_messages'; import { stopDevChatBase, sendMessageBase } from './sendMessageBase'; let _lastMessage: any = undefined; regInMessage({command: 'sendMessage', text: '', hash: undefined}); regOutMessage({ command: 'receiveMessage', text: 'xxxx', hash: 'xxx', user: 'xxx', date: 'xxx'}); regOutMessage({ command: 'receiveMessagePartial', text: 'xxxx', user: 'xxx', date: 'xxx'}); // message: { command: 'sendMessage', text: 'xxx', hash: 'xxx'} // return message: // { command: 'receiveMessage', text: 'xxxx', hash: 'xxx', user: 'xxx', date: 'xxx'} // { command: 'receiveMessagePartial', text: 'xxxx', user: 'xxx', date: 'xxx'} export async function sendMessage(message: any, panel: vscode.WebviewPanel|vscode.WebviewView): Promise { _lastMessage = message; const responseMessage = await sendMessageBase(message, (data: { command: string, text: string, user: string, date: string}) => { MessageHandler.sendMessage(panel, data); }); if (responseMessage) { MessageHandler.sendMessage(panel, responseMessage); } } // regeneration last message again regInMessage({command: 'regeneration'}); export async function regeneration(message: any, panel: vscode.WebviewPanel|vscode.WebviewView): Promise { // call sendMessage to send last message again if (_lastMessage) { sendMessage(_lastMessage, panel); } } regInMessage({command: 'stopDevChat'}); export async function stopDevChat(message: any, panel: vscode.WebviewPanel|vscode.WebviewView): Promise { stopDevChatBase(message); }