|
@ -1,2 +0,0 @@
|
||||||
*.sock
|
|
||||||
/node_modules/
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
{
|
||||||
|
"presets": [
|
||||||
|
[
|
||||||
|
"@babel/preset-env", {
|
||||||
|
"modules": false,
|
||||||
|
"loose": false,
|
||||||
|
"useBuiltIns": "usage"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"@babel/preset-stage-2", {
|
||||||
|
"modules": false,
|
||||||
|
"loose": false,
|
||||||
|
"useBuiltIns": true,
|
||||||
|
"decoratorsLegacy": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
],
|
||||||
|
"plugins": [
|
||||||
|
[
|
||||||
|
"@babel/transform-runtime", {
|
||||||
|
"polyfill": false,
|
||||||
|
"regenerator": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
],
|
||||||
|
"comments": false
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespace = true
|
|
@ -0,0 +1 @@
|
||||||
|
/dist
|
|
@ -0,0 +1,47 @@
|
||||||
|
module.exports = {
|
||||||
|
root: true,
|
||||||
|
parserOptions: {
|
||||||
|
parser: 'babel-eslint',
|
||||||
|
sourceType: 'module'
|
||||||
|
},
|
||||||
|
env: {
|
||||||
|
browser: true
|
||||||
|
},
|
||||||
|
extends: [
|
||||||
|
// https://github.com/vuejs/eslint-plugin-vue#priority-a-essential-error-prevention
|
||||||
|
// consider switching to `plugin:vue/strongly-recommended` or `plugin:vue/recommended` for stricter rules.
|
||||||
|
'plugin:vue/essential',
|
||||||
|
// https://github.com/standard/standard/blob/master/docs/RULES-en.md
|
||||||
|
'standard'
|
||||||
|
],
|
||||||
|
// required to lint *.vue files
|
||||||
|
plugins: [
|
||||||
|
'vue'
|
||||||
|
],
|
||||||
|
globals: {
|
||||||
|
'ga': true, // Google Analytics
|
||||||
|
'cordova': true,
|
||||||
|
'__statics': true
|
||||||
|
},
|
||||||
|
// add your custom rules here
|
||||||
|
'rules': {
|
||||||
|
// allow async-await
|
||||||
|
'generator-star-spacing': 'off',
|
||||||
|
|
||||||
|
// allow paren-less arrow functions
|
||||||
|
'arrow-parens': 0,
|
||||||
|
'one-var': 0,
|
||||||
|
|
||||||
|
'import/first': 0,
|
||||||
|
'import/named': 2,
|
||||||
|
'import/namespace': 2,
|
||||||
|
'import/default': 2,
|
||||||
|
'import/export': 2,
|
||||||
|
'import/extensions': 0,
|
||||||
|
'import/no-unresolved': 0,
|
||||||
|
'import/no-extraneous-dependencies': 0,
|
||||||
|
|
||||||
|
// allow debugger during development
|
||||||
|
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
.quasar
|
||||||
|
.DS_Store
|
||||||
|
.thumbs.db
|
||||||
|
node_modules
|
||||||
|
/dist
|
||||||
|
/src-cordova/platforms
|
||||||
|
/src-cordova/plugins
|
||||||
|
/src-cordova/www
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
|
||||||
|
# Editor directories and files
|
||||||
|
.idea
|
||||||
|
.vscode
|
||||||
|
*.suo
|
||||||
|
*.ntvs*
|
||||||
|
*.njsproj
|
||||||
|
*.sln
|
|
@ -0,0 +1,8 @@
|
||||||
|
// https://github.com/michael-ciniawsky/postcss-load-config
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
plugins: [
|
||||||
|
// to edit target browsers: use "browserslist" field in package.json
|
||||||
|
require('autoprefixer')
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
{
|
||||||
|
"blocks": "never",
|
||||||
|
"brackets": "never",
|
||||||
|
"colons": "never",
|
||||||
|
"colors": "always",
|
||||||
|
"commaSpace": "always",
|
||||||
|
"commentSpace": "always",
|
||||||
|
"cssLiteral": "never",
|
||||||
|
"depthLimit": false,
|
||||||
|
"duplicates": true,
|
||||||
|
"efficient": "always",
|
||||||
|
"extendPref": false,
|
||||||
|
"globalDupe": true,
|
||||||
|
"indentPref": 2,
|
||||||
|
"leadingZero": "never",
|
||||||
|
"maxErrors": false,
|
||||||
|
"maxWarnings": false,
|
||||||
|
"mixed": false,
|
||||||
|
"namingConvention": false,
|
||||||
|
"namingConventionStrict": false,
|
||||||
|
"none": "never",
|
||||||
|
"noImportant": false,
|
||||||
|
"parenSpace": "never",
|
||||||
|
"placeholder": false,
|
||||||
|
"prefixVarsWithDollar": "always",
|
||||||
|
"quotePref": "single",
|
||||||
|
"semicolons": "never",
|
||||||
|
"sortOrder": false,
|
||||||
|
"stackedProperties": "never",
|
||||||
|
"trailingWhitespace": "never",
|
||||||
|
"universal": "never",
|
||||||
|
"valid": true,
|
||||||
|
"zeroUnits": "never",
|
||||||
|
"zIndexNormalize": false
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
# Quasar App
|
||||||
|
|
||||||
|
> WIP
|
|
@ -0,0 +1,40 @@
|
||||||
|
{
|
||||||
|
"name": "client",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "simple web socket client tester",
|
||||||
|
"productName": "client",
|
||||||
|
"cordovaId": "org.cordova.quasar.app",
|
||||||
|
"author": "David Kebler <d@kebler.net>",
|
||||||
|
"private": true,
|
||||||
|
"scripts": {
|
||||||
|
"lint": "eslint --ext .js,.vue src",
|
||||||
|
"test": "echo \"No test specified\" && exit 0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@uci/websocket-client": "^0.1.2",
|
||||||
|
"axios": "^0.18.0",
|
||||||
|
"better-try-catch": "^0.6.2"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"babel-eslint": "^8.2.1",
|
||||||
|
"eslint": "^4.18.2",
|
||||||
|
"eslint-config-standard": "^11.0.0",
|
||||||
|
"eslint-friendly-formatter": "^4.0.1",
|
||||||
|
"eslint-loader": "^2.0.0",
|
||||||
|
"eslint-plugin-import": "^2.9.0",
|
||||||
|
"eslint-plugin-node": "^6.0.1",
|
||||||
|
"eslint-plugin-promise": "^3.7.0",
|
||||||
|
"eslint-plugin-standard": "^3.0.1",
|
||||||
|
"eslint-plugin-vue": "^4.3.0",
|
||||||
|
"quasar-cli": "^0.16.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 8.9.0",
|
||||||
|
"npm": ">= 5.6.0"
|
||||||
|
},
|
||||||
|
"browserslist": [
|
||||||
|
"> 1%",
|
||||||
|
"last 2 versions",
|
||||||
|
"not ie <= 10"
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,139 @@
|
||||||
|
// Configuration for your app
|
||||||
|
|
||||||
|
module.exports = function (ctx) {
|
||||||
|
return {
|
||||||
|
// app plugins (/src/plugins)
|
||||||
|
plugins: [
|
||||||
|
],
|
||||||
|
css: [
|
||||||
|
'app.styl'
|
||||||
|
],
|
||||||
|
extras: [
|
||||||
|
ctx.theme.mat ? 'roboto-font' : null,
|
||||||
|
'material-icons',
|
||||||
|
ctx.theme.ios ? 'ionicons' : null
|
||||||
|
// 'mdi',
|
||||||
|
// 'fontawesome'
|
||||||
|
],
|
||||||
|
supportIE: false,
|
||||||
|
build: {
|
||||||
|
scopeHoisting: true,
|
||||||
|
vueRouterMode: 'history',
|
||||||
|
// vueCompiler: true,
|
||||||
|
// gzip: true,
|
||||||
|
// analyze: true,
|
||||||
|
// extractCSS: false,
|
||||||
|
extendWebpack (cfg) {
|
||||||
|
cfg.module.rules.push({
|
||||||
|
enforce: 'pre',
|
||||||
|
test: /\.(js|vue)$/,
|
||||||
|
loader: 'eslint-loader',
|
||||||
|
exclude: /(node_modules|quasar)/
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
devServer: {
|
||||||
|
// https: true,
|
||||||
|
// port: 8080,
|
||||||
|
open: true // opens browser window automatically
|
||||||
|
},
|
||||||
|
// framework: 'all' --- includes everything; for dev only!
|
||||||
|
framework: {
|
||||||
|
components: [
|
||||||
|
'QLayout',
|
||||||
|
'QLayoutHeader',
|
||||||
|
'QLayoutDrawer',
|
||||||
|
'QPageContainer',
|
||||||
|
'QPage',
|
||||||
|
'QToolbar',
|
||||||
|
'QToolbarTitle',
|
||||||
|
'QBtn',
|
||||||
|
'QIcon',
|
||||||
|
'QList',
|
||||||
|
'QListHeader',
|
||||||
|
'QItem',
|
||||||
|
'QItemMain',
|
||||||
|
'QItemSide',
|
||||||
|
'QInput',
|
||||||
|
'QField'
|
||||||
|
],
|
||||||
|
directives: [
|
||||||
|
'Ripple'
|
||||||
|
],
|
||||||
|
// Quasar plugins
|
||||||
|
plugins: [
|
||||||
|
'Notify'
|
||||||
|
],
|
||||||
|
iconSet: ctx.theme.mat ? 'material-icons' : 'ionicons'
|
||||||
|
},
|
||||||
|
// animations: 'all' --- includes all animations
|
||||||
|
animations: [
|
||||||
|
],
|
||||||
|
pwa: {
|
||||||
|
// workboxPluginMode: 'InjectManifest',
|
||||||
|
// workboxOptions: {},
|
||||||
|
manifest: {
|
||||||
|
// name: 'Quasar App',
|
||||||
|
// short_name: 'Quasar-PWA',
|
||||||
|
// description: 'Best PWA App in town!',
|
||||||
|
display: 'standalone',
|
||||||
|
orientation: 'portrait',
|
||||||
|
background_color: '#ffffff',
|
||||||
|
theme_color: '#027be3',
|
||||||
|
icons: [
|
||||||
|
{
|
||||||
|
'src': 'statics/icons/icon-128x128.png',
|
||||||
|
'sizes': '128x128',
|
||||||
|
'type': 'image/png'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'src': 'statics/icons/icon-192x192.png',
|
||||||
|
'sizes': '192x192',
|
||||||
|
'type': 'image/png'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'src': 'statics/icons/icon-256x256.png',
|
||||||
|
'sizes': '256x256',
|
||||||
|
'type': 'image/png'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'src': 'statics/icons/icon-384x384.png',
|
||||||
|
'sizes': '384x384',
|
||||||
|
'type': 'image/png'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'src': 'statics/icons/icon-512x512.png',
|
||||||
|
'sizes': '512x512',
|
||||||
|
'type': 'image/png'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
cordova: {
|
||||||
|
// id: 'org.cordova.quasar.app'
|
||||||
|
},
|
||||||
|
electron: {
|
||||||
|
// bundler: 'builder', // or 'packager'
|
||||||
|
extendWebpack (cfg) {
|
||||||
|
// do something with Electron process Webpack cfg
|
||||||
|
},
|
||||||
|
packager: {
|
||||||
|
// https://github.com/electron-userland/electron-packager/blob/master/docs/api.md#options
|
||||||
|
|
||||||
|
// OS X / Mac App Store
|
||||||
|
// appBundleId: '',
|
||||||
|
// appCategoryType: '',
|
||||||
|
// osxSign: '',
|
||||||
|
// protocol: 'myapp://path',
|
||||||
|
|
||||||
|
// Window only
|
||||||
|
// win32metadata: { ... }
|
||||||
|
},
|
||||||
|
builder: {
|
||||||
|
// https://www.electron.build/configuration/configuration
|
||||||
|
|
||||||
|
// appId: 'quasar-app'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
<template>
|
||||||
|
<div id="q-app">
|
||||||
|
<router-view />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: 'App'
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
</style>
|
|
@ -0,0 +1,191 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||||
|
|
||||||
|
<svg
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
width="67.407623mm"
|
||||||
|
height="62.908276mm"
|
||||||
|
viewBox="0 0 238.84591 222.90334"
|
||||||
|
id="svg3570"
|
||||||
|
version="1.1"
|
||||||
|
inkscape:version="0.91 r13725"
|
||||||
|
sodipodi:docname="quasar-logo-full.svg">
|
||||||
|
<defs
|
||||||
|
id="defs3572" />
|
||||||
|
<sodipodi:namedview
|
||||||
|
id="base"
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="1.0"
|
||||||
|
inkscape:pageopacity="0.0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:zoom="1.979899"
|
||||||
|
inkscape:cx="-39.753589"
|
||||||
|
inkscape:cy="27.706388"
|
||||||
|
inkscape:document-units="px"
|
||||||
|
inkscape:current-layer="g4895-4-4"
|
||||||
|
showgrid="false"
|
||||||
|
fit-margin-top="0"
|
||||||
|
fit-margin-left="0"
|
||||||
|
fit-margin-right="0"
|
||||||
|
fit-margin-bottom="0"
|
||||||
|
inkscape:window-width="1920"
|
||||||
|
inkscape:window-height="1056"
|
||||||
|
inkscape:window-x="0"
|
||||||
|
inkscape:window-y="24"
|
||||||
|
inkscape:window-maximized="1" />
|
||||||
|
<metadata
|
||||||
|
id="metadata3575">
|
||||||
|
<rdf:RDF>
|
||||||
|
<cc:Work
|
||||||
|
rdf:about="">
|
||||||
|
<dc:format>image/svg+xml</dc:format>
|
||||||
|
<dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||||
|
<dc:title />
|
||||||
|
</cc:Work>
|
||||||
|
</rdf:RDF>
|
||||||
|
</metadata>
|
||||||
|
<g
|
||||||
|
inkscape:label="Layer 1"
|
||||||
|
inkscape:groupmode="layer"
|
||||||
|
id="layer1"
|
||||||
|
transform="translate(-277.71988,-312.33911)">
|
||||||
|
<g
|
||||||
|
id="g4895-4-4"
|
||||||
|
transform="translate(1419.0442,398.9018)">
|
||||||
|
<g
|
||||||
|
transform="translate(-29.620665,-4)"
|
||||||
|
id="g4579-2-20">
|
||||||
|
<g
|
||||||
|
id="g4445-2-0"
|
||||||
|
transform="translate(12.499948,7.809312)">
|
||||||
|
<g
|
||||||
|
inkscape:export-ydpi="44.860481"
|
||||||
|
inkscape:export-xdpi="44.860481"
|
||||||
|
inkscape:export-filename="/home/emanuele/Desktop/logo1.png"
|
||||||
|
transform="translate(-712.85583,-503.26814)"
|
||||||
|
id="g4561-6-7-0">
|
||||||
|
<g
|
||||||
|
transform="translate(16.233481,0)"
|
||||||
|
style="font-style:normal;font-weight:normal;font-size:50.25774765px;line-height:125%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#263238;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||||
|
id="flowRoot4513-6-6-08">
|
||||||
|
<path
|
||||||
|
d="m -402.73125,631.46823 q -0.6125,0.0438 -1.3125,0.0875 -0.65625,0 -1.4,0 l -9.31875,0 q -12.81875,0 -12.81875,-8.44375 l 0,-13.475 q 0,-8.26875 12.6,-8.26875 l 9.75625,0 q 12.6,0 12.6,8.26875 l 0,13.475 q 0,5.03125 -4.4625,7.04375 l 3.10625,2.14375 q 1.35625,0.83125 1.35625,1.70625 0,0.875 -0.7,1.3125 -0.65625,0.48125 -1.88125,0.48125 -0.30625,0 -0.7875,-0.13125 -0.4375,-0.0875 -1.05,-0.48125 l -5.6875,-3.71875 z m 5.38125,-21.74375 q 0,-4.76875 -7.9625,-4.76875 l -9.58125,0 q -7.9625,0 -7.9625,4.76875 l 0,13.3875 q 0,4.94375 8.3125,4.94375 l 8.88125,0 q 8.3125,0 8.3125,-4.94375 l 0,-13.3875 z"
|
||||||
|
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:43.75px;font-family:'Neuropol X';-inkscape-font-specification:'Neuropol X';text-align:start;letter-spacing:5px;word-spacing:0px;text-anchor:start;fill:#263238;fill-opacity:1"
|
||||||
|
id="path3428" />
|
||||||
|
<path
|
||||||
|
d="m -368.0585,631.64323 q -11.2875,0 -11.2875,-6.9125 l 0,-12.73125 q 0,-1.8375 2.31875,-1.8375 2.31875,0 2.31875,1.8375 l 0,12.775 q 0,3.325 6.475,3.325 l 8.3125,0 q 6.475,0 6.475,-3.325 l 0,-12.775 q 0,-1.8375 2.31875,-1.8375 2.3625,0 2.3625,1.8375 l 0,12.73125 q 0,6.9125 -11.2875,6.9125 l -8.00625,0 z"
|
||||||
|
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:43.75px;font-family:'Neuropol X';-inkscape-font-specification:'Neuropol X';text-align:start;letter-spacing:5px;word-spacing:0px;text-anchor:start;fill:#263238;fill-opacity:1"
|
||||||
|
id="path3430" />
|
||||||
|
<path
|
||||||
|
d="m -327.2833,631.64323 q -9.3625,0 -9.3625,-5.81875 l 0,-2.49375 q 0,-5.775 9.3625,-5.775 l 18.59375,0 0,-0.65625 q 0,-3.0625 -5.38125,-3.0625 l -6.16875,0 q -2.1875,0 -2.1875,-1.70625 0,-1.75 2.1875,-1.75 l 6.16875,0 q 9.93125,0 9.93125,6.51875 l 0,8.575 q 0,6.16875 -9.5375,6.16875 l -13.60625,0 z m 13.34375,-3.4125 q 5.25,0 5.25,-2.8875 l 0,-4.76875 -18.24375,0 q -5.11875,0 -5.11875,2.66875 l 0,2.275 q 0,2.7125 5.11875,2.7125 l 12.99375,0 z"
|
||||||
|
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:43.75px;font-family:'Neuropol X';-inkscape-font-specification:'Neuropol X';text-align:start;letter-spacing:5px;word-spacing:0px;text-anchor:start;fill:#263238;fill-opacity:1"
|
||||||
|
id="path3432" />
|
||||||
|
<path
|
||||||
|
d="m -262.77031,626.74323 q 0,4.9 -9.975,4.9 l -17.0625,0 q -2.1875,0 -2.1875,-1.70625 0,-1.70625 2.1875,-1.70625 l 17.0625,0 q 5.38125,0 5.38125,-1.4875 l 0,-2.45 q 0,-1.4875 -5.38125,-1.4875 l -9.0125,0 q -9.975,0 -9.975,-4.76875 l 0,-2.05625 q 0,-5.6 10.28125,-5.6 l 5.99375,0 q 2.23125,0 2.23125,1.75 0,0.875 -0.6125,1.3125 -0.56875,0.39375 -1.61875,0.39375 l -5.99375,0 q -5.73125,0 -5.73125,2.14375 l 0,1.925 q 0,1.79375 5.6875,1.79375 l 9.0125,0 q 9.7125,0 9.7125,4.4625 l 0,2.58125 z"
|
||||||
|
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:43.75px;font-family:'Neuropol X';-inkscape-font-specification:'Neuropol X';text-align:start;letter-spacing:5px;word-spacing:0px;text-anchor:start;fill:#263238;fill-opacity:1"
|
||||||
|
id="path3434" />
|
||||||
|
<path
|
||||||
|
d="m -241.91709,631.64323 q -9.3625,0 -9.3625,-5.81875 l 0,-2.49375 q 0,-5.775 9.3625,-5.775 l 18.59375,0 0,-0.65625 q 0,-3.0625 -5.38125,-3.0625 l -6.16875,0 q -2.1875,0 -2.1875,-1.70625 0,-1.75 2.1875,-1.75 l 6.16875,0 q 9.93125,0 9.93125,6.51875 l 0,8.575 q 0,6.16875 -9.5375,6.16875 l -13.60625,0 z m 13.34375,-3.4125 q 5.25,0 5.25,-2.8875 l 0,-4.76875 -18.24375,0 q -5.11875,0 -5.11875,2.66875 l 0,2.275 q 0,2.7125 5.11875,2.7125 l 12.99375,0 z"
|
||||||
|
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:43.75px;font-family:'Neuropol X';-inkscape-font-specification:'Neuropol X';text-align:start;letter-spacing:5px;word-spacing:0px;text-anchor:start;fill:#263238;fill-opacity:1"
|
||||||
|
id="path3436" />
|
||||||
|
<path
|
||||||
|
d="m -205.62285,617.33698 q 0,-6.95625 11.2875,-6.95625 l 3.36875,0 q 2.23125,0 2.23125,1.79375 0,1.79375 -2.23125,1.79375 l -3.54375,0 q -6.475,0 -6.475,3.28125 l 0,12.775 q 0,1.8375 -2.31875,1.8375 -2.31875,0 -2.31875,-1.8375 l 0,-12.6875 z"
|
||||||
|
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:43.75px;font-family:'Neuropol X';-inkscape-font-specification:'Neuropol X';text-align:start;letter-spacing:5px;word-spacing:0px;text-anchor:start;fill:#263238;fill-opacity:1"
|
||||||
|
id="path3438" />
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g5443-0-1-5-1-9"
|
||||||
|
transform="matrix(0.55595317,0,0,0.55595317,-521.93484,-328.66104)"
|
||||||
|
inkscape:export-filename="/home/emanuele/Desktop/logo1.png"
|
||||||
|
inkscape:export-xdpi="44.860481"
|
||||||
|
inkscape:export-ydpi="44.860481">
|
||||||
|
<g
|
||||||
|
inkscape:export-ydpi="3.4165223"
|
||||||
|
inkscape:export-xdpi="3.4165223"
|
||||||
|
transform="matrix(0.09527033,0,0,0.09527033,-1695.2716,706.62921)"
|
||||||
|
id="g8856-6-1-1-9-0-1-9">
|
||||||
|
<circle
|
||||||
|
r="1485"
|
||||||
|
cy="-1361.2571"
|
||||||
|
cx="8317.3574"
|
||||||
|
id="circle8858-1-3-7-6-5-3-0"
|
||||||
|
style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:50;stroke-linecap:square;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
inkscape:export-xdpi="10.031387"
|
||||||
|
inkscape:export-ydpi="10.031387" />
|
||||||
|
<path
|
||||||
|
inkscape:export-ydpi="10.031387"
|
||||||
|
inkscape:export-xdpi="10.031387"
|
||||||
|
style="opacity:1;fill:#263238;fill-opacity:1;stroke:none;stroke-width:10;stroke-linecap:square;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="m 8560.3823,-1361.3029 a 242.947,242.947 0 0 1 -242.947,242.948 242.947,242.947 0 0 1 -242.947,-242.948 242.947,242.947 0 0 1 242.947,-242.946 242.947,242.947 0 0 1 242.947,242.946 z"
|
||||||
|
id="path8860-5-4-8-2-9-0-9"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
<path
|
||||||
|
id="path8862-5-5-9-1-3-6-3"
|
||||||
|
d="m 9395.8755,-1984.028 a 1245.372,1245.372 0 0 0 -190.8415,-249.4971 l -280.8618,162.1556 c -87.542,-74.7796 -187.0349,-132.0588 -293.2407,-169.9527 -95.8868,97.1766 -172.0602,205.7604 -226.9672,323.8487 312.6411,-21.2772 635.5313,91.8725 935.2898,326.0721 l 176.7612,-102.0532 a 1245.372,1245.372 0 0 0 -120.1398,-290.5734 z"
|
||||||
|
clip-path="none"
|
||||||
|
mask="none"
|
||||||
|
style="fill:#1976d2;fill-opacity:1"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
inkscape:transform-center-x="-514.04855"
|
||||||
|
inkscape:transform-center-y="-444.04649" />
|
||||||
|
<path
|
||||||
|
inkscape:transform-center-y="265.80217"
|
||||||
|
inkscape:transform-center-x="-689.63727"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="fill:#42a5f5;fill-opacity:1"
|
||||||
|
mask="none"
|
||||||
|
clip-path="none"
|
||||||
|
d="m 9395.9474,-738.70387 a 1245.372,1245.372 0 0 0 120.6501,-290.02213 l -280.8618,-162.1557 c 20.99,-113.2034 20.8488,-228.0063 0.563,-338.9302 -132.1008,-34.4521 -264.2238,-46.1283 -393.9448,-34.635 174.7471,260.1165 238.2017,596.32248 185.2582,973.02076 l 176.7612,102.05309 a 1245.372,1245.372 0 0 0 191.5741,-249.33082 z"
|
||||||
|
id="path8864-4-8-1-2-4-4-4" />
|
||||||
|
<path
|
||||||
|
id="path8866-7-5-5-0-6-4-7"
|
||||||
|
d="m 8317.501,-115.97954 a 1245.372,1245.372 0 0 0 311.4916,-40.52501 l 0,-324.31131 c 108.5321,-38.42382 207.8837,-95.94755 293.8037,-168.97752 -36.214,-131.6287 -92.1636,-251.88868 -166.9776,-358.48372 -137.894,281.39369 -397.3296,504.44998 -750.0316,646.9487 l 0,204.10623 a 1245.372,1245.372 0 0 0 311.7139,41.24263 z"
|
||||||
|
clip-path="none"
|
||||||
|
mask="none"
|
||||||
|
style="fill:#1976d2;fill-opacity:1"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
inkscape:transform-center-x="-117.49007"
|
||||||
|
inkscape:transform-center-y="639.34029" />
|
||||||
|
<path
|
||||||
|
inkscape:transform-center-y="444.04652"
|
||||||
|
inkscape:transform-center-x="514.04857"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="fill:#42a5f5;fill-opacity:1"
|
||||||
|
mask="none"
|
||||||
|
clip-path="none"
|
||||||
|
d="m 7238.9827,-738.57936 a 1245.372,1245.372 0 0 0 190.8415,249.49714 l 280.8618,-162.15566 c 87.5421,74.77965 187.0349,132.05879 293.2407,169.95271 95.8868,-97.17659 172.0602,-205.76036 226.9672,-323.8487 -312.6411,21.27714 -635.5313,-91.87254 -935.2898,-326.07203 l -176.7612,102.0531 a 1245.372,1245.372 0 0 0 120.1398,290.57344 z"
|
||||||
|
id="path8868-6-7-4-7-2-7-3" />
|
||||||
|
<path
|
||||||
|
id="path8870-5-3-9-3-5-5-1"
|
||||||
|
d="m 7238.9108,-1983.9035 a 1245.372,1245.372 0 0 0 -120.6501,290.0221 l 280.8618,162.1557 c -20.99,113.2035 -20.8488,228.0063 -0.563,338.9302 132.1008,34.4521 264.2238,46.1283 393.9448,34.635 -174.7471,-260.1165 -238.2017,-596.3225 -185.2582,-973.0207 l -176.7612,-102.0532 a 1245.372,1245.372 0 0 0 -191.5741,249.3309 z"
|
||||||
|
clip-path="none"
|
||||||
|
mask="none"
|
||||||
|
style="fill:#1976d2;fill-opacity:1"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
inkscape:transform-center-x="689.63729"
|
||||||
|
inkscape:transform-center-y="-265.80221" />
|
||||||
|
<path
|
||||||
|
inkscape:transform-center-y="-639.34032"
|
||||||
|
inkscape:transform-center-x="117.49005"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="fill:#42a5f5;fill-opacity:1"
|
||||||
|
mask="none"
|
||||||
|
clip-path="none"
|
||||||
|
d="m 8317.3572,-2606.6279 a 1245.372,1245.372 0 0 0 -311.4915,40.525 l -1e-4,324.3113 c -108.5321,38.4239 -207.8837,95.9476 -293.8037,168.9776 36.214,131.6287 92.1637,251.8886 166.9776,358.4837 137.894,-281.3937 397.3296,-504.45 750.0316,-646.9487 l 1e-4,-204.1063 a 1245.372,1245.372 0 0 0 -311.714,-41.2426 z"
|
||||||
|
id="path8872-6-3-2-1-3-3-7" />
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 13 KiB |
After Width: | Height: | Size: 8.4 KiB |
|
@ -0,0 +1 @@
|
||||||
|
// app global css
|
|
@ -0,0 +1,25 @@
|
||||||
|
// App Shared Variables
|
||||||
|
// --------------------------------------------------
|
||||||
|
// To customize the look and feel of this app, you can override
|
||||||
|
// the Stylus variables found in Quasar's source Stylus files. Setting
|
||||||
|
// variables before Quasar's Stylus will use these variables rather than
|
||||||
|
// Quasar's default Stylus variable values. Stylus variables specific
|
||||||
|
// to the themes belong in either the variables.ios.styl or variables.mat.styl files.
|
||||||
|
|
||||||
|
// Check documentation for full list of Quasar variables
|
||||||
|
|
||||||
|
|
||||||
|
// App Shared Color Variables
|
||||||
|
// --------------------------------------------------
|
||||||
|
// It's highly recommended to change the default colors
|
||||||
|
// to match your app's branding.
|
||||||
|
|
||||||
|
$primary = #027be3
|
||||||
|
$secondary = #26A69A
|
||||||
|
$tertiary = #555
|
||||||
|
|
||||||
|
$neutral = #E0E1E2
|
||||||
|
$positive = #21BA45
|
||||||
|
$negative = #DB2828
|
||||||
|
$info = #31CCEC
|
||||||
|
$warning = #F2C037
|
|
@ -0,0 +1,7 @@
|
||||||
|
// App Shared Variables
|
||||||
|
// --------------------------------------------------
|
||||||
|
// Shared Stylus variables go in the common.variables.styl file
|
||||||
|
@import 'common.variables'
|
||||||
|
|
||||||
|
// iOS only Quasar variables overwrites
|
||||||
|
// -----------------------------------------
|
|
@ -0,0 +1,7 @@
|
||||||
|
// App Shared Variables
|
||||||
|
// --------------------------------------------------
|
||||||
|
// Shared Stylus variables go in the common.variables.styl file
|
||||||
|
@import 'common.variables'
|
||||||
|
|
||||||
|
// Material only Quasar variables overwrites
|
||||||
|
// -----------------------------------------
|
|
@ -0,0 +1,25 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="description" content="<%= htmlWebpackPlugin.options.productDescription %>">
|
||||||
|
<meta name="format-detection" content="telephone=no">
|
||||||
|
<meta name="msapplication-tap-highlight" content="no">
|
||||||
|
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width<% if (htmlWebpackPlugin.options.ctx.mode.cordova) { %>, viewport-fit=cover<% } %>">
|
||||||
|
<title><%= htmlWebpackPlugin.options.productName %></title>
|
||||||
|
|
||||||
|
<link rel="icon" href="statics/quasar-logo.png" type="image/x-icon">
|
||||||
|
<link rel="icon" type="image/png" sizes="32x32" href="statics/icons/favicon-32x32.png">
|
||||||
|
<link rel="icon" type="image/png" sizes="16x16" href="statics/icons/favicon-16x16.png">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<noscript>
|
||||||
|
This is your fallback content in case JavaScript fails to load.
|
||||||
|
</noscript>
|
||||||
|
|
||||||
|
<!-- DO NOT touch the following <div> -->
|
||||||
|
<div id="q-app"></div>
|
||||||
|
|
||||||
|
<!-- built files will be auto injected here -->
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,38 @@
|
||||||
|
<template>
|
||||||
|
<q-layout view="lHh Lpr lFf">
|
||||||
|
<q-layout-header>
|
||||||
|
<q-toolbar
|
||||||
|
color="primary"
|
||||||
|
:glossy="$q.theme === 'mat'"
|
||||||
|
:inverted="$q.theme === 'ios'"
|
||||||
|
>
|
||||||
|
<q-toolbar-title>
|
||||||
|
UCI Web Socket
|
||||||
|
<div slot="subtitle">web socket tester</div>
|
||||||
|
</q-toolbar-title>
|
||||||
|
</q-toolbar>
|
||||||
|
</q-layout-header>
|
||||||
|
<q-page-container>
|
||||||
|
<router-view />
|
||||||
|
</q-page-container>
|
||||||
|
</q-layout>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { openURL } from 'quasar'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'LayoutDefault',
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
leftDrawerOpen: this.$q.platform.is.desktop
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
openURL
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
</style>
|
|
@ -0,0 +1,16 @@
|
||||||
|
<template>
|
||||||
|
<div class="fixed-center text-center">
|
||||||
|
<p>
|
||||||
|
<img
|
||||||
|
src="~assets/sad.svg"
|
||||||
|
style="width:30vw;max-width:150px;"
|
||||||
|
>
|
||||||
|
</p>
|
||||||
|
<p class="text-faded">Sorry, nothing here...<strong>(404)</strong></p>
|
||||||
|
<q-btn
|
||||||
|
color="secondary"
|
||||||
|
style="width:200px;"
|
||||||
|
@click="$router.push('/')"
|
||||||
|
>Go back</q-btn>
|
||||||
|
</div>
|
||||||
|
</template>
|
|
@ -0,0 +1,62 @@
|
||||||
|
<template>
|
||||||
|
<q-page class="justify-center">
|
||||||
|
<q-list padding class="row justify-center">
|
||||||
|
<q-field
|
||||||
|
label="Command"
|
||||||
|
helper="command to execute on server"
|
||||||
|
>
|
||||||
|
<q-input inverted color="secondary" v-model="cmd" />
|
||||||
|
</q-field>
|
||||||
|
<q-field
|
||||||
|
label="Payload"
|
||||||
|
helper="payload/data to send with command"
|
||||||
|
>
|
||||||
|
<q-input inverted color="secondary" v-model="payload" />
|
||||||
|
</q-field>
|
||||||
|
<q-btn round @click="send" icon="email" />
|
||||||
|
</q-list>
|
||||||
|
<q-input rows="5" v-model="response" readonly inverted type="textarea" float-label="Server Response:" />
|
||||||
|
</q-page>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
|
||||||
|
import btc from 'better-try-catch'
|
||||||
|
import socket from '../plugins/socket.js'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
cmd: '',
|
||||||
|
payload: '',
|
||||||
|
response: ''
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
async send () {
|
||||||
|
let packet = {cmd: this.cmd, payload: this.payload}
|
||||||
|
let res = await socket.send(packet)
|
||||||
|
if (typeof res === 'string') this.response = res
|
||||||
|
else {
|
||||||
|
if (this[res.cmd]) this[res.cmd](res.response)
|
||||||
|
else this.response = `no action for returned command ${res.cmd}`
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async doit (response) {
|
||||||
|
this.response = `response via doit: ${response}`
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async mounted () {
|
||||||
|
console.log('mounting')
|
||||||
|
this.$q.notify({type: 'info', message: `Client connecting to', ${socket.url}`})
|
||||||
|
let [err] = await btc(socket.connect)()
|
||||||
|
if (err) { this.$q.notify({type: 'negative', message: 'Websocket Server Not Available'}) } else {
|
||||||
|
this.$q.notify({type: 'positive', message: 'Ready'})
|
||||||
|
socket.listen()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
</style>
|
|
@ -0,0 +1,11 @@
|
||||||
|
// import WebSocket from '@uci/websocket-client'
|
||||||
|
import WebSocket from '../../../../../uci-websocket-client/browser-client'
|
||||||
|
|
||||||
|
const ws = new WebSocket(process.env.WSS || 'ws://0.0.0.0:8090')
|
||||||
|
|
||||||
|
export { ws }
|
||||||
|
|
||||||
|
// leave the export, even if you don't use it
|
||||||
|
export default ({ Vue }) => {
|
||||||
|
Vue.prototype.$socket = ws
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
import axios from 'axios'
|
||||||
|
|
||||||
|
export default ({ Vue }) => {
|
||||||
|
// we add it to Vue prototype
|
||||||
|
// so we can reference it in Vue files
|
||||||
|
// without the need to import axios
|
||||||
|
Vue.prototype.$axios = axios
|
||||||
|
|
||||||
|
// Example: this.$axios will reference Axios now so you don't need stuff like vue-axios
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
import Vue from 'vue'
|
||||||
|
import VueRouter from 'vue-router'
|
||||||
|
|
||||||
|
import routes from './routes'
|
||||||
|
|
||||||
|
Vue.use(VueRouter)
|
||||||
|
|
||||||
|
const Router = new VueRouter({
|
||||||
|
/*
|
||||||
|
* NOTE! Change Vue Router mode from quasar.conf.js -> build -> vueRouterMode
|
||||||
|
*
|
||||||
|
* When going with "history" mode, please also make sure "build.publicPath"
|
||||||
|
* is set to something other than an empty string.
|
||||||
|
* Example: '/' instead of ''
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Leave as is and change from quasar.conf.js instead!
|
||||||
|
mode: process.env.VUE_ROUTER_MODE,
|
||||||
|
base: process.env.VUE_ROUTER_BASE,
|
||||||
|
scrollBehavior: () => ({ y: 0 }),
|
||||||
|
routes
|
||||||
|
})
|
||||||
|
|
||||||
|
export default Router
|
|
@ -0,0 +1,15 @@
|
||||||
|
|
||||||
|
export default [
|
||||||
|
{
|
||||||
|
path: '/',
|
||||||
|
component: () => import('layouts/default'),
|
||||||
|
children: [
|
||||||
|
{ path: '', component: () => import('pages/index') }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
{ // Always leave this as last one
|
||||||
|
path: '*',
|
||||||
|
component: () => import('pages/404')
|
||||||
|
}
|
||||||
|
]
|
After Width: | Height: | Size: 13 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 2.5 KiB |
After Width: | Height: | Size: 7.0 KiB |
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 29 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 7.0 KiB |
|
@ -1,35 +1,24 @@
|
||||||
import { Socket } from '../src'
|
import { Socket } from '../src'
|
||||||
|
|
||||||
|
async function packetProcess (packet) {
|
||||||
|
return new Promise(resolve => {
|
||||||
|
let res = {}
|
||||||
|
if (packet.cmd !== 'doit') {
|
||||||
|
res.response = `the payload sent was: ${packet.payload} with command ${packet.cmd}`
|
||||||
|
} else {
|
||||||
|
res.cmd = 'doit'
|
||||||
|
res.response = 'take some action in browser like color a button green' }
|
||||||
|
resolve (res)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// let test = new Test()
|
||||||
|
let test = new Socket({port:8090, clientTracking:true})
|
||||||
|
test.registerPacketProcessor(packetProcess)
|
||||||
|
|
||||||
;
|
;
|
||||||
(async () => {
|
(async () => {
|
||||||
|
|
||||||
class Test extends Socket {
|
|
||||||
constructor(opts) {
|
|
||||||
super(opts)
|
|
||||||
}
|
|
||||||
|
|
||||||
// async _packetProcess(packet) {
|
|
||||||
// console.log('packet being processed at socket', packet)
|
|
||||||
// if (packet.cmd) return await this[packet.cmd](packet.data,packet.name)
|
|
||||||
// return {error: 'no command in packet', packet: packet }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// async doit(data,name) {
|
|
||||||
// return new Promise(resolve => {
|
|
||||||
// let res = {}
|
|
||||||
// console.log('data sent to doit = ', data)
|
|
||||||
// res.status ='success'
|
|
||||||
// res.name = name
|
|
||||||
// res.cmd = 'reply'
|
|
||||||
// res.data = data
|
|
||||||
// resolve(res)
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// let test = new Test()
|
|
||||||
let test = new Test({port:8090})
|
|
||||||
console.log(await test.create())
|
console.log(await test.create())
|
||||||
|
|
||||||
})().catch(err => {
|
})().catch(err => {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@uci/websocket",
|
"name": "@uci/websocket",
|
||||||
"version": "0.1.6",
|
"version": "0.1.9",
|
||||||
"description": "JSON packet host websocket server",
|
"description": "JSON packet host websocket server",
|
||||||
"main": "src",
|
"main": "src",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -35,16 +35,16 @@
|
||||||
"chai": "^4.1.2",
|
"chai": "^4.1.2",
|
||||||
"chai-as-promised": "^7.1.1",
|
"chai-as-promised": "^7.1.1",
|
||||||
"codecov": "^3.0.0",
|
"codecov": "^3.0.0",
|
||||||
"esm": "^3.0.21",
|
"esm": "^3.0.34",
|
||||||
"istanbul": "^0.4.5",
|
"istanbul": "^0.4.5",
|
||||||
"mocha": "^5.0.1",
|
"mocha": "^5.0.1",
|
||||||
"nodemon": "^1.15.1"
|
"nodemon": "^1.15.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@uci/logger": "0.0.1",
|
"@uci/logger": "0.0.3",
|
||||||
"better-try-catch": "^0.6.2",
|
"better-try-catch": "^0.6.2",
|
||||||
"clone": "^2.1.1",
|
"clone": "^2.1.1",
|
||||||
"death": "^1.1.0",
|
"death": "^1.1.0",
|
||||||
"ws": "^5.1.0"
|
"ws": "^5.1.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,8 @@ let log = {}
|
||||||
export default class Socket extends WebSocket.Server {
|
export default class Socket extends WebSocket.Server {
|
||||||
constructor (opts = {}) {
|
constructor (opts = {}) {
|
||||||
opts.host = opts.host || '0.0.0.0'
|
opts.host = opts.host || '0.0.0.0'
|
||||||
opts.port = opts.port || 8080
|
opts.port = opts.port || 8090
|
||||||
|
opts.clientTracking = opts.clientTracking || true
|
||||||
super(opts)
|
super(opts)
|
||||||
this.id = opts.id || opts.name || 'Websocket:'+ new Date().getTime()
|
this.id = opts.id || opts.name || 'Websocket:'+ new Date().getTime()
|
||||||
this.opts = opts // for use to recover from selected errors
|
this.opts = opts // for use to recover from selected errors
|
||||||
|
@ -43,7 +44,7 @@ export default class Socket extends WebSocket.Server {
|
||||||
this.on('listening', async () => {
|
this.on('listening', async () => {
|
||||||
this._listen()
|
this._listen()
|
||||||
log.info('websocket server created and listening at', this.address())
|
log.info('websocket server created and listening at', this.address())
|
||||||
resolve('websocket ready and listening')
|
resolve(`websocket ready and listening at ${this.address().address}:${this.address().port}`)
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
@ -56,27 +57,37 @@ export default class Socket extends WebSocket.Server {
|
||||||
|
|
||||||
_listen () {
|
_listen () {
|
||||||
|
|
||||||
this.on('connection', async (socket) => {
|
this.on('connection', async (socket, req) => {
|
||||||
const send = this._send.bind(socket)
|
let send = this._send.bind(socket)
|
||||||
log.info('new consumer connecting')
|
log.info({req:req},'new consumer connecting')
|
||||||
socket.on('message', messageProcess.bind(this))
|
socket.address = req.remoteAddress
|
||||||
|
socket.on('message', messageProcess.bind(this,socket))
|
||||||
|
|
||||||
async function messageProcess (strPacket) {
|
async function messageProcess (client,strPacket) {
|
||||||
log.info(' incoming packet on socket side')
|
log.info({packet:strPacket},' incoming packet on web socket side')
|
||||||
let res = {}
|
let res = {}
|
||||||
let [err, packet] = btc(JSON.parse)(strPacket)
|
let [err, packet] = btc(JSON.parse)(strPacket)
|
||||||
|
log.info('packet', err, packet)
|
||||||
if (err) { res = {error: `Could not parse JSON: ${packet}`} }
|
if (err) { res = {error: `Could not parse JSON: ${packet}`} }
|
||||||
else {
|
else {
|
||||||
res = await this._packetProcess(clone(packet))
|
if (packet.clientID) {
|
||||||
|
client.ID = packet.clientID
|
||||||
|
res.cmd='ackID'
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
res = await this._packetProcess(clone(packet)) || {}
|
||||||
if (Object.keys(res).length === 0) res = { error: 'socket packet command function likely did not return a promise', packet:packet}
|
if (Object.keys(res).length === 0) res = { error: 'socket packet command function likely did not return a promise', packet:packet}
|
||||||
}
|
}
|
||||||
res._header = clone(packet._header,false) //make sure return packet has header with id in case it was removed in processing
|
}
|
||||||
|
if (packet) {
|
||||||
|
res._header = clone(packet._header,false) || {} //make sure return packet has header with id in case it was removed in processing
|
||||||
delete packet._header // remove before adding to response header as request
|
delete packet._header // remove before adding to response header as request
|
||||||
|
} else res._header = {}
|
||||||
res._header.request = clone(packet,false)
|
res._header.request = clone(packet,false)
|
||||||
res._header.responder = {name:this.name,instanceID:this.id}
|
res._header.responder = {name:this.name,instanceID:this.id}
|
||||||
res._header.socket = this.address()
|
res._header.socket = this.address()
|
||||||
if (!res.cmd) res.cmd = 'reply' // by default return command is 'reply'
|
if (!res.cmd) res.cmd = 'reply' // by default return command is 'reply'
|
||||||
log.info(await send(res))
|
log.info({packet:res},await send(res))
|
||||||
}
|
}
|
||||||
|
|
||||||
}) // end connected consumer
|
}) // end connected consumer
|
||||||
|
@ -97,14 +108,22 @@ export default class Socket extends WebSocket.Server {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// must have a consumer socket instance bound to call this!!
|
async push (packet,id) {
|
||||||
|
this.clients.forEach(async (client) => {
|
||||||
|
if (client.readyState === WebSocket.OPEN) {
|
||||||
|
if (!id || id ===client.ID ) await this._send.bind(client)(packet)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// must have a consumer socket instance bound to call this function
|
||||||
async _send (packet) {
|
async _send (packet) {
|
||||||
return new Promise( (resolve,reject) => {
|
return new Promise( (resolve,reject) => {
|
||||||
if (this.readyState !== 1 ) reject (`Connection not Ready, CODE:${this.readyState}`)
|
if (this.readyState !== 1 ) reject (`Connection not Ready, CODE:${this.readyState}`)
|
||||||
let [err,message] = btc(JSON.stringify)(packet)
|
let [err,message] = btc(JSON.stringify)(packet)
|
||||||
if (err) reject(`Could not JSON stringify: ${packet}`)
|
if (err) reject(`Could not JSON stringify: ${packet}`)
|
||||||
this.send(message)
|
this.send(message)
|
||||||
resolve('sent packet', packet)
|
resolve('sent packet')
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|