mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
Update
This commit is contained in:
@@ -23,10 +23,24 @@ export class SynchroService {
|
||||
private id: string = uuidv4();
|
||||
public conected = false
|
||||
private url: string = ''
|
||||
callback = function(){}
|
||||
|
||||
constructor(){}
|
||||
|
||||
setUrl(wss:wss) {
|
||||
setUrl() {
|
||||
|
||||
let header ={
|
||||
id:'1234',
|
||||
bluePrint: '12312123',
|
||||
jwt: uuidv4()
|
||||
}
|
||||
|
||||
let wss: wss ={
|
||||
header,
|
||||
url: 'wss://synchro-server.herokuapp.com/ws/some_url/',
|
||||
type: 'reflect'
|
||||
}
|
||||
|
||||
this.url = `${wss.url}${wss.header.id}/${wss.header.jwt}/${wss.header.bluePrint}/${this.id}/`
|
||||
}
|
||||
|
||||
@@ -42,19 +56,28 @@ export class SynchroService {
|
||||
|
||||
private onopen = () =>{
|
||||
console.log('open ======================= welcome to socket server')
|
||||
// this.connection.send(JSON.stringify({user:'user1'}));
|
||||
|
||||
}
|
||||
|
||||
public $send = (object: any) => {
|
||||
let sendData = JSON.stringify(Object.assign({}, object));
|
||||
public $send(object: any) {
|
||||
|
||||
let message = {
|
||||
message: '{"person.adress.country":"1Angola"}',
|
||||
username: '',
|
||||
idConnection: this.id
|
||||
}
|
||||
|
||||
let sendData = JSON.stringify(Object.assign({}, message));
|
||||
|
||||
this.connection.send(sendData);
|
||||
}
|
||||
|
||||
private onmessage = async (event: any)=> {
|
||||
|
||||
// alert('message')
|
||||
this.callback()
|
||||
}
|
||||
|
||||
private onclose=(event:any)=>{
|
||||
private onclose=(event:any)=> {
|
||||
setTimeout(() => {
|
||||
if (event.wasClean) {
|
||||
console.log(`[close] Connection closed cleanly, code=${event.code} reason=${event.reason}`);
|
||||
@@ -72,3 +95,8 @@ export class SynchroService {
|
||||
console.log(`[error] ${event.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const connection = new SynchroService()
|
||||
connection.setUrl()
|
||||
connection.connect()
|
||||
Reference in New Issue
Block a user