mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 18:44:16 +00:00
include legacy method
This commit is contained in:
parent
b9e2d3a03d
commit
9433138e6d
@ -3,7 +3,7 @@
|
|||||||
"UUID": "C8mVSr-4nmPp2-pr5Vrz-CU4kg4",
|
"UUID": "C8mVSr-4nmPp2-pr5Vrz-CU4kg4",
|
||||||
"title": "Comty™",
|
"title": "Comty™",
|
||||||
"DevBuild": true,
|
"DevBuild": true,
|
||||||
"version": "0.9.26",
|
"version": "0.10.6",
|
||||||
"stage": "dev",
|
"stage": "dev",
|
||||||
"description": "",
|
"description": "",
|
||||||
"author": "RageStudio",
|
"author": "RageStudio",
|
||||||
|
@ -13,7 +13,7 @@ const exportCodeRender = (data) => {
|
|||||||
return <div style={{ textAlign: 'center', width: '100%', padding: '30px 0 30px 0' }}>
|
return <div style={{ textAlign: 'center', width: '100%', padding: '30px 0 30px 0' }}>
|
||||||
<Icons.HardDrive style={{ fontSize: '45px', margin: '0' }} />
|
<Icons.HardDrive style={{ fontSize: '45px', margin: '0' }} />
|
||||||
<h4>Hey, this file is too much large!</h4>
|
<h4>Hey, this file is too much large!</h4>
|
||||||
<span>So it couldn't be displayed.</span>
|
<h3>So it couldn't be displayed.</h3>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
return <div>
|
return <div>
|
||||||
|
@ -1,29 +0,0 @@
|
|||||||
import { uri_resolver } from 'api/lib'
|
|
||||||
import io from 'socket.io-client'
|
|
||||||
import { connect } from 'umi'
|
|
||||||
import settings from 'core/libs/settings'
|
|
||||||
|
|
||||||
@connect(({ app }) => ({ app }))
|
|
||||||
export default class SocketConnection{
|
|
||||||
state = {
|
|
||||||
model: settings("app_model"),
|
|
||||||
resolvers: this.props.app.resolvers
|
|
||||||
}
|
|
||||||
constructor(){
|
|
||||||
console.log(model)
|
|
||||||
this.opts = {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
conn = {
|
|
||||||
create: () => {
|
|
||||||
|
|
||||||
},
|
|
||||||
destroy: () => {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
92
src/core/libs/socket/index.ts
Normal file
92
src/core/libs/socket/index.ts
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
import io from 'socket.io-client'
|
||||||
|
import { verbosityConsole } from 'core/libs/verbosity'
|
||||||
|
import { connect } from 'umi'
|
||||||
|
import settings from 'core/libs/settings'
|
||||||
|
|
||||||
|
const maxDeep_Attemp = Number(2)
|
||||||
|
export class SocketConnection{
|
||||||
|
ioConn: any
|
||||||
|
state: { address: any; connAttemps: number }
|
||||||
|
props: any
|
||||||
|
opts: any
|
||||||
|
|
||||||
|
constructor(props:any){
|
||||||
|
if (!props) {
|
||||||
|
throw new Error("Mmm some props are not defined")
|
||||||
|
}
|
||||||
|
this.state = {
|
||||||
|
address: props.address,
|
||||||
|
connAttemps: Number(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
this.props = props
|
||||||
|
this.opts = {
|
||||||
|
reconnection: true,
|
||||||
|
reconnectionAttempts: Infinity,
|
||||||
|
reconnectionDelay: 1000,
|
||||||
|
reconnectionDelayMax: 5000,
|
||||||
|
randomizationFactor: 0.5,
|
||||||
|
timeout: 20000,
|
||||||
|
autoConnect: false,
|
||||||
|
query: {},
|
||||||
|
// options of the Engine.IO client
|
||||||
|
upgrade: true,
|
||||||
|
forceJSONP: false,
|
||||||
|
jsonp: true,
|
||||||
|
forceBase64: false,
|
||||||
|
enablesXDR: false,
|
||||||
|
timestampRequests: true,
|
||||||
|
timestampParam: 't',
|
||||||
|
policyPort: 843,
|
||||||
|
transports: ['polling', 'websocket'],
|
||||||
|
transportOptions: {},
|
||||||
|
rememberUpgrade: false,
|
||||||
|
onlyBinaryUpgrades: false,
|
||||||
|
requestTimeout: 0,
|
||||||
|
protocols: [],
|
||||||
|
// options for Node.js
|
||||||
|
agent: false,
|
||||||
|
pfx: null,
|
||||||
|
key: null,
|
||||||
|
passphrase: null,
|
||||||
|
cert: null,
|
||||||
|
ca: null,
|
||||||
|
ciphers: [],
|
||||||
|
rejectUnauthorized: true,
|
||||||
|
perMessageDeflate: true,
|
||||||
|
forceNode: false,
|
||||||
|
localAddress: null,
|
||||||
|
// options for Node.js / React Native
|
||||||
|
extraHeaders: {},
|
||||||
|
}
|
||||||
|
this.ioConn = io(this.state.address, this.opts)
|
||||||
|
this.conn.open()
|
||||||
|
this.ioConn.on("connect_error", () => {
|
||||||
|
if (this.state.connAttemps >= maxDeep_Attemp) {
|
||||||
|
verbosityConsole('Maximun nº of attemps reached => max', maxDeep_Attemp + 1)
|
||||||
|
this.conn.close()
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
verbosityConsole(`Strike [${this.state.connAttemps + 1}] / ${maxDeep_Attemp + 1} !`)
|
||||||
|
this.state.connAttemps = this.state.connAttemps + 1
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
conn = {
|
||||||
|
open: () => {
|
||||||
|
this.ioConn.open()
|
||||||
|
},
|
||||||
|
disconnect: () => {
|
||||||
|
this.ioConn.disconnect()
|
||||||
|
},
|
||||||
|
close: () => {
|
||||||
|
verbosity("Connection closed!")
|
||||||
|
this.ioConn.close()
|
||||||
|
},
|
||||||
|
destroy: () => {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -4,7 +4,32 @@ import stackTrace from 'stack-trace'
|
|||||||
import path from 'path'
|
import path from 'path'
|
||||||
const verbosity_enabled = settings('verbosity')
|
const verbosity_enabled = settings('verbosity')
|
||||||
|
|
||||||
export function verbosity(data, params){
|
export const verbosity = {
|
||||||
|
log: (...cont) => {
|
||||||
|
return verbosity_enabled ? console.log(...cont) : null
|
||||||
|
},
|
||||||
|
debug: (...cont) => {
|
||||||
|
const frame = stackTrace.get()[1]
|
||||||
|
// const line = frame.getLineNumber()
|
||||||
|
// const file = path.basename(frame.getFileName())
|
||||||
|
const method = frame.getFunctionName()
|
||||||
|
|
||||||
|
return verbosity_enabled ? console.debug(`%c[${method}]`, 'color: #bada55', ...cont) : null
|
||||||
|
},
|
||||||
|
error: (...cont) => {
|
||||||
|
const frame = stackTrace.get()[1]
|
||||||
|
// const line = frame.getLineNumber()
|
||||||
|
// const file = path.basename(frame.getFileName())
|
||||||
|
const method = frame.getFunctionName()
|
||||||
|
|
||||||
|
return verbosity_enabled ? console.error(`%c[${method}]`, 'color: #bada55', ...cont) : null
|
||||||
|
},
|
||||||
|
warn: (...cont) => {
|
||||||
|
return verbosity_enabled ? console.warn(...cont) : null
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
export function verbosityConsole(data, params){
|
||||||
if(!verbosity_enabled) return false
|
if(!verbosity_enabled) return false
|
||||||
let optString = []
|
let optString = []
|
||||||
const frame = stackTrace.get()[1]
|
const frame = stackTrace.get()[1]
|
||||||
@ -17,7 +42,7 @@ export function verbosity(data, params){
|
|||||||
let opt = {
|
let opt = {
|
||||||
stackTrace: {
|
stackTrace: {
|
||||||
method: true,
|
method: true,
|
||||||
line: false,
|
line: true,
|
||||||
file: false
|
file: false
|
||||||
},
|
},
|
||||||
color: "#bada55",
|
color: "#bada55",
|
||||||
|
@ -9,10 +9,13 @@ import { uri_resolver } from 'api/lib'
|
|||||||
import jwt from 'jsonwebtoken'
|
import jwt from 'jsonwebtoken'
|
||||||
import cookie from 'cookie_js'
|
import cookie from 'cookie_js'
|
||||||
import { usePlugins } from 'plugins'
|
import { usePlugins } from 'plugins'
|
||||||
|
import { SocketConnection } from 'core/libs/socket/index.ts'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
namespace: 'app',
|
namespace: 'app',
|
||||||
state: {
|
state: {
|
||||||
|
env_proccess: process.env,
|
||||||
|
socket_conn: null,
|
||||||
server_key: keys.server_key,
|
server_key: keys.server_key,
|
||||||
resolvers: null,
|
resolvers: null,
|
||||||
|
|
||||||
@ -76,7 +79,6 @@ export default {
|
|||||||
|
|
||||||
cancelRequest.forEach((value, key) => {
|
cancelRequest.forEach((value, key) => {
|
||||||
if (value.pathname !== window.location.pathname) {
|
if (value.pathname !== window.location.pathname) {
|
||||||
value.cancel('cancel request');
|
|
||||||
cancelRequest.delete(key);
|
cancelRequest.delete(key);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -92,11 +94,9 @@ export default {
|
|||||||
window.PluginGlobals = []
|
window.PluginGlobals = []
|
||||||
|
|
||||||
if (!service) {
|
if (!service) {
|
||||||
console.error('❌ Cannot connect with validate session service!')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sessionDataframe && session ) {
|
if (!sessionDataframe && session ) {
|
||||||
console.log('Updating dataframe!')
|
|
||||||
yield put({ type: 'handleUpdateData' })
|
yield put({ type: 'handleUpdateData' })
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,6 +134,12 @@ export default {
|
|||||||
},
|
},
|
||||||
*guestLogin({ payload }, { put, select }) {
|
*guestLogin({ payload }, { put, select }) {
|
||||||
|
|
||||||
|
},
|
||||||
|
*initializeSocket({payload}, {select}){
|
||||||
|
if(!payload) return false
|
||||||
|
|
||||||
|
new SocketConnection(payload)
|
||||||
|
|
||||||
},
|
},
|
||||||
*initializePlugins({ payload }, { select }){
|
*initializePlugins({ payload }, { select }){
|
||||||
const extended = yield select(state => state.extended)
|
const extended = yield select(state => state.extended)
|
||||||
@ -187,13 +193,11 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Array.isArray(RequireImport)) {
|
if (Array.isArray(RequireImport)) {
|
||||||
console.log("Require array")
|
|
||||||
RequireImport.forEach((e) => {
|
RequireImport.forEach((e) => {
|
||||||
console.log(`Importing " ${e} " from [ ${RequireFrom} ]`)
|
console.log(`Importing " ${e} " from [ ${RequireFrom} ]`)
|
||||||
extendedRequire[e] = require(RequireFrom)
|
extendedRequire[e] = require(RequireFrom)
|
||||||
})
|
})
|
||||||
}else{
|
}else{
|
||||||
console.log("Require default")
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -245,7 +249,6 @@ export default {
|
|||||||
sessionAuthframe = jwt.decode(sessionAuthframe)
|
sessionAuthframe = jwt.decode(sessionAuthframe)
|
||||||
yield put({ type: 'handleUpdateAuthFrames', payload: sessionAuthframe })
|
yield put({ type: 'handleUpdateAuthFrames', payload: sessionAuthframe })
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
verbosity.error('Invalid AUTHFRAME !', error)
|
|
||||||
cookie.remove(app_config.session_token_storage)
|
cookie.remove(app_config.session_token_storage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -254,7 +257,6 @@ export default {
|
|||||||
sessionDataframe = JSON.parse(atob(sessionDataframe))
|
sessionDataframe = JSON.parse(atob(sessionDataframe))
|
||||||
yield put({ type: 'handleUpdateDataFrames', payload: sessionDataframe })
|
yield put({ type: 'handleUpdateDataFrames', payload: sessionDataframe })
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
verbosity.error('Invalid DATAFRAME !', error, session)
|
|
||||||
sessionDataframe = null
|
sessionDataframe = null
|
||||||
sessionStorage.clear()
|
sessionStorage.clear()
|
||||||
}
|
}
|
||||||
@ -301,7 +303,6 @@ export default {
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (tokenExp < now) {
|
if (tokenExp < now) {
|
||||||
verbosity.debug('This token is expired !!!')
|
|
||||||
state.session_valid = false
|
state.session_valid = false
|
||||||
}else{
|
}else{
|
||||||
state.session_valid = true
|
state.session_valid = true
|
||||||
@ -340,8 +341,6 @@ export default {
|
|||||||
state.session_authframe = token
|
state.session_authframe = token
|
||||||
})
|
})
|
||||||
|
|
||||||
appInterface.notify.success('Login done!')
|
|
||||||
router.push('/')
|
|
||||||
state.session_valid = true
|
state.session_valid = true
|
||||||
location.reload()
|
location.reload()
|
||||||
},
|
},
|
||||||
@ -368,11 +367,9 @@ export default {
|
|||||||
|
|
||||||
},
|
},
|
||||||
handleThemeChange(state, { payload }) {
|
handleThemeChange(state, { payload }) {
|
||||||
store.set('theme', payload);
|
|
||||||
state.theme = payload;
|
state.theme = payload;
|
||||||
},
|
},
|
||||||
handleCollapseSidebar(state, { payload }){
|
handleCollapseSidebar(state, { payload }){
|
||||||
store.set('sidebar_collapse', payload);
|
|
||||||
state.sidebar_collapsed = payload
|
state.sidebar_collapsed = payload
|
||||||
},
|
},
|
||||||
isUser(state, { payload, callback }){
|
isUser(state, { payload, callback }){
|
||||||
@ -410,7 +407,6 @@ export default {
|
|||||||
if (!payload || !state.embedded) {
|
if (!payload || !state.embedded) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
console.log('INVOKING => ', payload)
|
|
||||||
const ipc = state.electron.ipcRenderer
|
const ipc = state.electron.ipcRenderer
|
||||||
|
|
||||||
ipc.invoke(payload.key, payload.payload)
|
ipc.invoke(payload.key, payload.payload)
|
||||||
@ -419,7 +415,6 @@ export default {
|
|||||||
if (!payload || !state.embedded) {
|
if (!payload || !state.embedded) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
console.log('send INVOKING => ', payload)
|
|
||||||
const ipc = state.electron.ipcRenderer
|
const ipc = state.electron.ipcRenderer
|
||||||
ipc.send(payload.key, payload.payload)
|
ipc.send(payload.key, payload.payload)
|
||||||
},
|
},
|
||||||
@ -441,7 +436,6 @@ export default {
|
|||||||
state.session_authframe = null;
|
state.session_authframe = null;
|
||||||
cookie.remove(app_config.session_token_storage)
|
cookie.remove(app_config.session_token_storage)
|
||||||
sessionStorage.clear()
|
sessionStorage.clear()
|
||||||
router.push('/')
|
|
||||||
location.reload()
|
location.reload()
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -5,13 +5,27 @@ import io from 'socket.io-client'
|
|||||||
import { connect } from 'umi'
|
import { connect } from 'umi'
|
||||||
import * as antd from 'antd'
|
import * as antd from 'antd'
|
||||||
import { objectToArray } from 'core'
|
import { objectToArray } from 'core'
|
||||||
|
import settings from 'core/libs/settings'
|
||||||
|
|
||||||
|
const defaultSocketAddress = "85.251.59.39"
|
||||||
|
|
||||||
@connect(({ app }) => ({ app }))
|
@connect(({ app }) => ({ app }))
|
||||||
export default class SocketDebug extends React.Component{
|
export default class SocketDebug extends React.Component{
|
||||||
state = {
|
state = {
|
||||||
resolvers: objectToArray(this.props.app.resolvers),
|
resolvers: objectToArray(this.props.app.resolvers),
|
||||||
connNode: null,
|
connNode: null,
|
||||||
|
InputRaw: defaultSocketAddress
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dispatchSocket(value){
|
||||||
|
this.props.dispatch({
|
||||||
|
type: `${settings("app_model")}/initializeSocket`,
|
||||||
|
payload: {
|
||||||
|
address: value
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
render(){
|
render(){
|
||||||
return(
|
return(
|
||||||
<div>
|
<div>
|
||||||
@ -29,6 +43,13 @@ export default class SocketDebug extends React.Component{
|
|||||||
</antd.Card>
|
</antd.Card>
|
||||||
|
|
||||||
connectedNode: {this.state.connNode}
|
connectedNode: {this.state.connNode}
|
||||||
|
|
||||||
|
<antd.Card>
|
||||||
|
<antd.Button onClick={() => this.setState({ InputRaw: defaultSocketAddress })} > Set default </antd.Button>
|
||||||
|
<antd.Button onClick={() => this.dispatchSocket(this.state.InputRaw)} > connect </antd.Button>
|
||||||
|
<antd.Input onChange={(e) => this.setState({ InputRaw: e.target.value })} value={this.state.InputRaw} placeholder="ws:// http:// some.bruh:9090" />
|
||||||
|
</antd.Card>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user