Comments (2)
You can do it like this.
` var wsUri = 'wss://yourURL/api/socket';
function init()
{
myWebSocket();
}
function myWebSocket()
{
websocket = new WebSocket(wsUri);
websocket.onopen = function(evt) { onOpen(evt) };
websocket.onclose = function(evt) { onClose(evt) };
websocket.onmessage = function(evt) { onMessage(evt) };
websocket.onerror = function(evt) { onError(evt) };
}
function onOpen(evt)
{
// Define what you want to do "onOpen" here
console.log("Websocket Connected");
}
function onClose(evt)
{
// Define what you want to do "onClose" here
console.log("Websocket Disconnected");
setTimeout(function() {
init();
}, 10000);
}
function onMessage(evt)
{
// Define what you want to do "onMessage" here. This is where you will receive the responses
console.log("RESPONSE: " + evt.data);
}
function onError(evt)
{
// Define what you want to do "onError" here
}
window.addEventListener("load", init, false);
`
from traccar-api-php.
@nabadawa Your example or answer does not address the issue or question being asked. Please post response when you have accurate answer to the specifics being sought
@esdan7 I am closing this ticket, based on the discussions we had over email with reference to CORS and session handling.
from traccar-api-php.
Related Issues (17)
- how to using of php api tarccar how to install? HOT 11
- Geofences HOT 3
- Fetching devices HOT 4
- sessionId in gps::devices method HOT 2
- Events API HOT 1
- code
- api-use example HOT 3
- how could i contact to you HOT 2
- How to create session and receive data from Websocket HOT 1
- UI HOT 2
- what to send as $cookie parameter for any function HOT 5
- link/unlink objects HOT 1
- Admin Access Required upon edit user HOT 1
- Updates November 2018 HOT 1
- Redeclared function HOT 2
- Geo-Fence HOT 12
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from traccar-api-php.