Implement basic support for connecting to wings console via websocket rather than socketio
This commit is contained in:
parent
0757d8856b
commit
e87c5f6657
12 changed files with 122 additions and 117 deletions
|
@ -34,6 +34,11 @@
|
|||
Databases
|
||||
</router-link>
|
||||
</li>
|
||||
<li>
|
||||
<router-link :to="{ name: 'server-network' }">
|
||||
Networking
|
||||
</router-link>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -54,7 +59,6 @@
|
|||
import Vue from 'vue';
|
||||
import Navigation from '@/components/core/Navigation.vue';
|
||||
import {mapState} from 'vuex';
|
||||
import * as io from 'socket.io-client';
|
||||
import {Socketio} from "@/mixins/socketio";
|
||||
import PowerButtons from "@/components/server/components/PowerButtons.vue";
|
||||
import Flash from "@/components/Flash.vue";
|
||||
|
@ -105,13 +109,12 @@
|
|||
this.$store.dispatch('server/getCredentials', {server: this.$route.params.id})
|
||||
])
|
||||
.then(() => {
|
||||
// Configure the socket.io implementation. This is a really ghetto way of handling things
|
||||
// but all of these plugins assume you have some constant connection, which we don't.
|
||||
const socket = io(`${this.credentials.node}/v1/ws/${this.server.uuid}`, {
|
||||
query: `token=${this.credentials.key}`,
|
||||
});
|
||||
// Configure the websocket implementation and assign it to the mixin.
|
||||
this.$socket().connect(
|
||||
`ws://192.168.50.3:8080/api/servers/${this.server.uuid}/ws`,
|
||||
'CC8kHCuMkXPosgzGO6d37wvhNcksWxG6kTrA',
|
||||
);
|
||||
|
||||
this.$socket().connect(socket);
|
||||
this.loadingServerData = false;
|
||||
})
|
||||
.catch(err => {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<div v-if="connected">
|
||||
<transition name="slide-fade" mode="out-in">
|
||||
<button class="btn btn-green uppercase text-xs px-4 py-2"
|
||||
v-if="status === statuses.STATUS_OFF"
|
||||
v-if="status === 'offline'"
|
||||
v-on:click.prevent="sendPowerAction('start')"
|
||||
>Start
|
||||
</button>
|
||||
|
@ -45,7 +45,7 @@
|
|||
|
||||
methods: {
|
||||
sendPowerAction: function (action: string) {
|
||||
this.$socket().instance().emit('set status', action)
|
||||
this.$socket().emit('set state', action)
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
@ -64,20 +64,12 @@
|
|||
* Listen for specific socket.io emits from the server.
|
||||
*/
|
||||
sockets: {
|
||||
'server log': function (data: string) {
|
||||
data.split(/\n/g).forEach((line: string): void => {
|
||||
if (this.terminal) {
|
||||
this.terminal.writeln(line + '\u001b[0m');
|
||||
}
|
||||
});
|
||||
'server log': function (lines: Array<string>) {
|
||||
lines.forEach(data => data.split(/\n/g).forEach(line => this.terminal && this.terminal.writeln(line + '\u001b[0m')));
|
||||
},
|
||||
|
||||
'console': function (data: { line: string }) {
|
||||
data.line.split(/\n/g).forEach((line: string): void => {
|
||||
if (this.terminal) {
|
||||
this.terminal.writeln(line + '\u001b[0m');
|
||||
}
|
||||
});
|
||||
'console output': function (line: string) {
|
||||
this.terminal && this.terminal.writeln(line.replace(/(?:\r\n|\r|\n)$/im, '') + '\u001b[0m');
|
||||
},
|
||||
},
|
||||
|
||||
|
@ -114,7 +106,7 @@
|
|||
this.terminal.fit();
|
||||
this.terminal.clear();
|
||||
|
||||
this.$socket().instance().emit('send server log');
|
||||
this.$socket().emit('send logs');
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -123,7 +115,7 @@
|
|||
sendCommand: function () {
|
||||
this.commandHistoryIndex = -1;
|
||||
this.commandHistory.unshift(this.command);
|
||||
this.$socket().instance().emit('send command', this.command);
|
||||
this.$socket().emit('send command', this.command);
|
||||
this.command = '';
|
||||
},
|
||||
|
||||
|
|
Reference in a new issue