Migrating from Flux to Redux. Why and how.Astrails
When I started to work with React back in Apr-2015 there were many libraries to manage the application flow. I decided to start with classical FB's Flux implementation to understand what's missed there. Eventually react-redux and redux solved most of issues I had with Flux. This talk is about practical aspects of migration from Flux to Redux.
Solid principles in practice the clean architecture - Droidcon ItalyFabio Collini
The Clean Architecture has been formalized by Robert C. Martin in 2012, it's quite new even if it's based on the SOLID principles (presented for the first time in early 2000). The biggest benefit that we get using this architecture is the code testability, indeed it separates the application code from the code connected to external factor (that usually is more difficult to test).
In this talk we'll see a practical example of how to apply the SOLID principle, in particular, the dependency inversion.
Migrating from Flux to Redux. Why and how.Astrails
When I started to work with React back in Apr-2015 there were many libraries to manage the application flow. I decided to start with classical FB's Flux implementation to understand what's missed there. Eventually react-redux and redux solved most of issues I had with Flux. This talk is about practical aspects of migration from Flux to Redux.
Solid principles in practice the clean architecture - Droidcon ItalyFabio Collini
The Clean Architecture has been formalized by Robert C. Martin in 2012, it's quite new even if it's based on the SOLID principles (presented for the first time in early 2000). The biggest benefit that we get using this architecture is the code testability, indeed it separates the application code from the code connected to external factor (that usually is more difficult to test).
In this talk we'll see a practical example of how to apply the SOLID principle, in particular, the dependency inversion.
This is my presentation from TechBeats #3 hosted by Applause about Server-Side Swift framework called Vapor.
Swift is a great language and possibility of using it also in backend is a huge benefit for any iOS developer out there. Using Vapor is a seamless experience. With this framework creating advance APIs by iOS developer is as easy as writing simple iOS app.
https://www.meetup.com/TechBeats-hosted-by-Applause/events/254910023/
By now, you’ve probably heard of Akka, the JVM toolkit for building scalable, resilient and resource efficient applications in Java or Scala. With over 12 open-source and commercial modules in the toolkit, Akka takes developers from actors on a single JVM, all the way out to network partition healing and clusters of servers distributed across fleets of JVMs.
In this technical webinar, O’Reilly author and Lightbend Developer Advocate, Hugh McKee, takes you on a deep dive into advanced Akka features for enhanced application resilience, elasticity, and responsiveness.
Building on real-world examples from his past experience as an Akka developer, Hugh will show how you can take advantage of:
• Akka Multi-Data Center Clustering improves reliability across multiple data centers, availability zones or regions.
• Logically grouping related nodes in large clusters to improve stability and scalability.
• Akka Multi-Data Center Persistence for increased fault tolerance, locate data near the user, and balance the load across data centers.
• Akka Cluster Sharding in a multi data center environment, to optimize shard locality within a single data center and go Active-Active for improved resilience and availability.
How to use geolocation in react native appsInnovationM
Geolocation will find your current location and Geocoding gives your address (like City Name, Street Name, etc) by Coordinates (Latitude and Longitude).
What is Geolocation?
The most famous and familiar location feature — Geolocation is the ability to track a device using GPS, cell phone towers, WiFi access points or a combination of these. Since devices area unit employed by people, geolocation uses positioning systems to trace associate degree individual’s whereabouts right down to latitude and great circle coordinates, or more practically, a physical address. Both mobile and desktop devices can use geolocation.
Geolocation is accustomed to confirm zone and actual positioning coordinates, like for chase life or shipment shipments.
Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017Codemotion
What if someone told you that you could use the full capacity of your server? That you could have the same performance on the backend as your react frontend? Don't you believe it? That you could choose the best language/tool for the task and you were not limited by what you already know? In this talk, I'll show you that you can use the full power of React on the frontend and Vert.x on the backend. You will see a fast full stack development workflow with Rollup/Webpack + Babel + React. How you can mix JavaScript with any other language. Build microservice applications in minutes.
This is my talk on ReactiveCocoa at @cocoaheads_at in Vienna. I gave an introduction to reactive programming with RAC and an overview of signals and subscribers, and how they can be used to create useful patterns.
Como desarrollar una App estilo Uber para el mercado Mexicano. Se explicaran el uso de frameworks de websockets, geolocalización, pagos y más.
Fernando Gutiérrez Lozano (@fernando_gl_) y Salvador Rodríguez Dávila (@srdzdv)
Managing State in React Apps with RxJS by James Wright at FrontCon 2019DevClub_lv
Redux is one of the most popular technologies for the management of shared state across entire React applications, which can be complemented by Redux Observable to describe asynchronous side effects with RxJS. This approach, however, adds cognitive load when balancing the varying concepts across these three libraries. What if we could use RxJS exclusively for managing state in our React apps? This talk will demonstrate this possibility and the benefits it provides.
This is my presentation from TechBeats #3 hosted by Applause about Server-Side Swift framework called Vapor.
Swift is a great language and possibility of using it also in backend is a huge benefit for any iOS developer out there. Using Vapor is a seamless experience. With this framework creating advance APIs by iOS developer is as easy as writing simple iOS app.
https://www.meetup.com/TechBeats-hosted-by-Applause/events/254910023/
By now, you’ve probably heard of Akka, the JVM toolkit for building scalable, resilient and resource efficient applications in Java or Scala. With over 12 open-source and commercial modules in the toolkit, Akka takes developers from actors on a single JVM, all the way out to network partition healing and clusters of servers distributed across fleets of JVMs.
In this technical webinar, O’Reilly author and Lightbend Developer Advocate, Hugh McKee, takes you on a deep dive into advanced Akka features for enhanced application resilience, elasticity, and responsiveness.
Building on real-world examples from his past experience as an Akka developer, Hugh will show how you can take advantage of:
• Akka Multi-Data Center Clustering improves reliability across multiple data centers, availability zones or regions.
• Logically grouping related nodes in large clusters to improve stability and scalability.
• Akka Multi-Data Center Persistence for increased fault tolerance, locate data near the user, and balance the load across data centers.
• Akka Cluster Sharding in a multi data center environment, to optimize shard locality within a single data center and go Active-Active for improved resilience and availability.
How to use geolocation in react native appsInnovationM
Geolocation will find your current location and Geocoding gives your address (like City Name, Street Name, etc) by Coordinates (Latitude and Longitude).
What is Geolocation?
The most famous and familiar location feature — Geolocation is the ability to track a device using GPS, cell phone towers, WiFi access points or a combination of these. Since devices area unit employed by people, geolocation uses positioning systems to trace associate degree individual’s whereabouts right down to latitude and great circle coordinates, or more practically, a physical address. Both mobile and desktop devices can use geolocation.
Geolocation is accustomed to confirm zone and actual positioning coordinates, like for chase life or shipment shipments.
Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017Codemotion
What if someone told you that you could use the full capacity of your server? That you could have the same performance on the backend as your react frontend? Don't you believe it? That you could choose the best language/tool for the task and you were not limited by what you already know? In this talk, I'll show you that you can use the full power of React on the frontend and Vert.x on the backend. You will see a fast full stack development workflow with Rollup/Webpack + Babel + React. How you can mix JavaScript with any other language. Build microservice applications in minutes.
This is my talk on ReactiveCocoa at @cocoaheads_at in Vienna. I gave an introduction to reactive programming with RAC and an overview of signals and subscribers, and how they can be used to create useful patterns.
Como desarrollar una App estilo Uber para el mercado Mexicano. Se explicaran el uso de frameworks de websockets, geolocalización, pagos y más.
Fernando Gutiérrez Lozano (@fernando_gl_) y Salvador Rodríguez Dávila (@srdzdv)
Managing State in React Apps with RxJS by James Wright at FrontCon 2019DevClub_lv
Redux is one of the most popular technologies for the management of shared state across entire React applications, which can be complemented by Redux Observable to describe asynchronous side effects with RxJS. This approach, however, adds cognitive load when balancing the varying concepts across these three libraries. What if we could use RxJS exclusively for managing state in our React apps? This talk will demonstrate this possibility and the benefits it provides.
State of ICS and IoT Cyber Threat Landscape Report 2024 previewPrayukth K V
The IoT and OT threat landscape report has been prepared by the Threat Research Team at Sectrio using data from Sectrio, cyber threat intelligence farming facilities spread across over 85 cities around the world. In addition, Sectrio also runs AI-based advanced threat and payload engagement facilities that serve as sinks to attract and engage sophisticated threat actors, and newer malware including new variants and latent threats that are at an earlier stage of development.
The latest edition of the OT/ICS and IoT security Threat Landscape Report 2024 also covers:
State of global ICS asset and network exposure
Sectoral targets and attacks as well as the cost of ransom
Global APT activity, AI usage, actor and tactic profiles, and implications
Rise in volumes of AI-powered cyberattacks
Major cyber events in 2024
Malware and malicious payload trends
Cyberattack types and targets
Vulnerability exploit attempts on CVEs
Attacks on counties – USA
Expansion of bot farms – how, where, and why
In-depth analysis of the cyber threat landscape across North America, South America, Europe, APAC, and the Middle East
Why are attacks on smart factories rising?
Cyber risk predictions
Axis of attacks – Europe
Systemic attacks in the Middle East
Download the full report from here:
https://sectrio.com/resources/ot-threat-landscape-reports/sectrio-releases-ot-ics-and-iot-security-threat-landscape-report-2024/
Essentials of Automations: Optimizing FME Workflows with ParametersSafe Software
Are you looking to streamline your workflows and boost your projects’ efficiency? Do you find yourself searching for ways to add flexibility and control over your FME workflows? If so, you’re in the right place.
Join us for an insightful dive into the world of FME parameters, a critical element in optimizing workflow efficiency. This webinar marks the beginning of our three-part “Essentials of Automation” series. This first webinar is designed to equip you with the knowledge and skills to utilize parameters effectively: enhancing the flexibility, maintainability, and user control of your FME projects.
Here’s what you’ll gain:
- Essentials of FME Parameters: Understand the pivotal role of parameters, including Reader/Writer, Transformer, User, and FME Flow categories. Discover how they are the key to unlocking automation and optimization within your workflows.
- Practical Applications in FME Form: Delve into key user parameter types including choice, connections, and file URLs. Allow users to control how a workflow runs, making your workflows more reusable. Learn to import values and deliver the best user experience for your workflows while enhancing accuracy.
- Optimization Strategies in FME Flow: Explore the creation and strategic deployment of parameters in FME Flow, including the use of deployment and geometry parameters, to maximize workflow efficiency.
- Pro Tips for Success: Gain insights on parameterizing connections and leveraging new features like Conditional Visibility for clarity and simplicity.
We’ll wrap up with a glimpse into future webinars, followed by a Q&A session to address your specific questions surrounding this topic.
Don’t miss this opportunity to elevate your FME expertise and drive your projects to new heights of efficiency.
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualityInflectra
In this insightful webinar, Inflectra explores how artificial intelligence (AI) is transforming software development and testing. Discover how AI-powered tools are revolutionizing every stage of the software development lifecycle (SDLC), from design and prototyping to testing, deployment, and monitoring.
Learn about:
• The Future of Testing: How AI is shifting testing towards verification, analysis, and higher-level skills, while reducing repetitive tasks.
• Test Automation: How AI-powered test case generation, optimization, and self-healing tests are making testing more efficient and effective.
• Visual Testing: Explore the emerging capabilities of AI in visual testing and how it's set to revolutionize UI verification.
• Inflectra's AI Solutions: See demonstrations of Inflectra's cutting-edge AI tools like the ChatGPT plugin and Azure Open AI platform, designed to streamline your testing process.
Whether you're a developer, tester, or QA professional, this webinar will give you valuable insights into how AI is shaping the future of software delivery.
DevOps and Testing slides at DASA ConnectKari Kakkonen
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
Epistemic Interaction - tuning interfaces to provide information for AI supportAlan Dix
Paper presented at SYNERGY workshop at AVI 2024, Genoa, Italy. 3rd June 2024
https://alandix.com/academic/papers/synergy2024-epistemic/
As machine learning integrates deeper into human-computer interactions, the concept of epistemic interaction emerges, aiming to refine these interactions to enhance system adaptability. This approach encourages minor, intentional adjustments in user behaviour to enrich the data available for system learning. This paper introduces epistemic interaction within the context of human-system communication, illustrating how deliberate interaction design can improve system understanding and adaptation. Through concrete examples, we demonstrate the potential of epistemic interaction to significantly advance human-computer interaction by leveraging intuitive human communication strategies to inform system design and functionality, offering a novel pathway for enriching user-system engagements.
JMeter webinar - integration with InfluxDB and GrafanaRTTS
Watch this recorded webinar about real-time monitoring of application performance. See how to integrate Apache JMeter, the open-source leader in performance testing, with InfluxDB, the open-source time-series database, and Grafana, the open-source analytics and visualization application.
In this webinar, we will review the benefits of leveraging InfluxDB and Grafana when executing load tests and demonstrate how these tools are used to visualize performance metrics.
Length: 30 minutes
Session Overview
-------------------------------------------
During this webinar, we will cover the following topics while demonstrating the integrations of JMeter, InfluxDB and Grafana:
- What out-of-the-box solutions are available for real-time monitoring JMeter tests?
- What are the benefits of integrating InfluxDB and Grafana into the load testing stack?
- Which features are provided by Grafana?
- Demonstration of InfluxDB and Grafana using a practice web application
To view the webinar recording, go to:
https://www.rttsweb.com/jmeter-integration-webinar
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...UiPathCommunity
💥 Speed, accuracy, and scaling – discover the superpowers of GenAI in action with UiPath Document Understanding and Communications Mining™:
See how to accelerate model training and optimize model performance with active learning
Learn about the latest enhancements to out-of-the-box document processing – with little to no training required
Get an exclusive demo of the new family of UiPath LLMs – GenAI models specialized for processing different types of documents and messages
This is a hands-on session specifically designed for automation developers and AI enthusiasts seeking to enhance their knowledge in leveraging the latest intelligent document processing capabilities offered by UiPath.
Speakers:
👨🏫 Andras Palfi, Senior Product Manager, UiPath
👩🏫 Lenka Dulovicova, Product Program Manager, UiPath
Key Trends Shaping the Future of Infrastructure.pdfCheryl Hung
Keynote at DIGIT West Expo, Glasgow on 29 May 2024.
Cheryl Hung, ochery.com
Sr Director, Infrastructure Ecosystem, Arm.
The key trends across hardware, cloud and open-source; exploring how these areas are likely to mature and develop over the short and long-term, and then considering how organisations can position themselves to adapt and thrive.
Search and Society: Reimagining Information Access for Radical FuturesBhaskar Mitra
The field of Information retrieval (IR) is currently undergoing a transformative shift, at least partly due to the emerging applications of generative AI to information access. In this talk, we will deliberate on the sociotechnical implications of generative AI for information access. We will argue that there is both a critical necessity and an exciting opportunity for the IR community to re-center our research agendas on societal needs while dismantling the artificial separation between the work on fairness, accountability, transparency, and ethics in IR and the rest of IR research. Instead of adopting a reactionary strategy of trying to mitigate potential social harms from emerging technologies, the community should aim to proactively set the research agenda for the kinds of systems we should build inspired by diverse explicitly stated sociotechnical imaginaries. The sociotechnical imaginaries that underpin the design and development of information access technologies needs to be explicitly articulated, and we need to develop theories of change in context of these diverse perspectives. Our guiding future imaginaries must be informed by other academic fields, such as democratic theory and critical theory, and should be co-developed with social science scholars, legal scholars, civil rights and social justice activists, and artists, among others.
Accelerate your Kubernetes clusters with Varnish CachingThijs Feryn
A presentation about the usage and availability of Varnish on Kubernetes. This talk explores the capabilities of Varnish caching and shows how to use the Varnish Helm chart to deploy it to Kubernetes.
This presentation was delivered at K8SUG Singapore. See https://feryn.eu/presentations/accelerate-your-kubernetes-clusters-with-varnish-caching-k8sug-singapore-28-2024 for more details.
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
GraphRAG is All You need? LLM & Knowledge GraphGuy Korland
Guy Korland, CEO and Co-founder of FalkorDB, will review two articles on the integration of language models with knowledge graphs.
1. Unifying Large Language Models and Knowledge Graphs: A Roadmap.
https://arxiv.org/abs/2306.08302
2. Microsoft Research's GraphRAG paper and a review paper on various uses of knowledge graphs:
https://www.microsoft.com/en-us/research/blog/graphrag-unlocking-llm-discovery-on-narrative-private-data/
Connector Corner: Automate dynamic content and events by pushing a buttonDianaGray10
Here is something new! In our next Connector Corner webinar, we will demonstrate how you can use a single workflow to:
Create a campaign using Mailchimp with merge tags/fields
Send an interactive Slack channel message (using buttons)
Have the message received by managers and peers along with a test email for review
But there’s more:
In a second workflow supporting the same use case, you’ll see:
Your campaign sent to target colleagues for approval
If the “Approve” button is clicked, a Jira/Zendesk ticket is created for the marketing design team
But—if the “Reject” button is pushed, colleagues will be alerted via Slack message
Join us to learn more about this new, human-in-the-loop capability, brought to you by Integration Service connectors.
And...
Speakers:
Akshay Agnihotri, Product Manager
Charlie Greenberg, Host
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
The publishing industry has been selling digital audiobooks and ebooks for over a decade and has found its groove. What’s changed? What has stayed the same? Where do we go from here? Join a group of leading sales peers from across the industry for a conversation about the lessons learned since the popularization of digital books, best practices, digital book supply chain management, and more.
Link to video recording: https://bnctechforum.ca/sessions/selling-digital-books-in-2024-insights-from-industry-leaders/
Presented by BookNet Canada on May 28, 2024, with support from the Department of Canadian Heritage.
Neuro-symbolic is not enough, we need neuro-*semantic*Frank van Harmelen
Neuro-symbolic (NeSy) AI is on the rise. However, simply machine learning on just any symbolic structure is not sufficient to really harvest the gains of NeSy. These will only be gained when the symbolic structures have an actual semantics. I give an operational definition of semantics as “predictable inference”.
All of this illustrated with link prediction over knowledge graphs, but the argument is general.
Neuro-symbolic is not enough, we need neuro-*semantic*
Creating an Uber Clone - Part XV - Transcript.pdf
1. Creating an Uber Clone - Part XV
Next we’ll bind the websocket logic and map UI to bring this all together…
2. public class LocationService {
private static final short MESSAGE_TYPE_LOCATION_UPDATE = 1;
private static final short MESSAGE_TYPE_DRIVER_POSITIONS = 2;
private static final short MESSAGE_TYPE_AVAILBLE_DRIVER_POSITIONS = 3;
private static final long MAX_UPDATE_FREQUENCY = 3000;
private Location lastKnownLocation;
private SocketConnection server;
private CarAdded carCallback;
private SuccessCallback<Location> locationCallback;
private Map<Long, User> cars = new HashMap<>();
private LocationService() {}
public static void bind(CarAdded carCallback,
SuccessCallback<Location> locationUpdate) {
new LocationService().bindImpl(carCallback, locationUpdate);
}
private void bindImpl(CarAdded carCallback,
SuccessCallback<Location> locationUpdate) {
this.carCallback = carCallback;
locationCallback = locationUpdate;
LocationManager.getLocationManager().
setLocationListener(new LocationListener() {
@Override
LocationService (Client)
We can get started with a LocationService class similarly to the UserService class that would abstract the local location. Unlike the UserService class the LocationService
class should also deal with the physical location of the device.
These are the same constants we have in the server
3. public class LocationService {
private static final short MESSAGE_TYPE_LOCATION_UPDATE = 1;
private static final short MESSAGE_TYPE_DRIVER_POSITIONS = 2;
private static final short MESSAGE_TYPE_AVAILBLE_DRIVER_POSITIONS = 3;
private static final long MAX_UPDATE_FREQUENCY = 3000;
private Location lastKnownLocation;
private SocketConnection server;
private CarAdded carCallback;
private SuccessCallback<Location> locationCallback;
private Map<Long, User> cars = new HashMap<>();
private LocationService() {}
public static void bind(CarAdded carCallback,
SuccessCallback<Location> locationUpdate) {
new LocationService().bindImpl(carCallback, locationUpdate);
}
private void bindImpl(CarAdded carCallback,
SuccessCallback<Location> locationUpdate) {
this.carCallback = carCallback;
locationCallback = locationUpdate;
LocationManager.getLocationManager().
setLocationListener(new LocationListener() {
@Override
LocationService (Client)
When sending a location update to the server I don't want to exceed a fixed amount of updates so we won't burden the server or our network
4. public class LocationService {
private static final short MESSAGE_TYPE_LOCATION_UPDATE = 1;
private static final short MESSAGE_TYPE_DRIVER_POSITIONS = 2;
private static final short MESSAGE_TYPE_AVAILBLE_DRIVER_POSITIONS = 3;
private static final long MAX_UPDATE_FREQUENCY = 3000;
private Location lastKnownLocation;
private SocketConnection server;
private CarAdded carCallback;
private SuccessCallback<Location> locationCallback;
private Map<Long, User> cars = new HashMap<>();
private LocationService() {}
public static void bind(CarAdded carCallback,
SuccessCallback<Location> locationUpdate) {
new LocationService().bindImpl(carCallback, locationUpdate);
}
private void bindImpl(CarAdded carCallback,
SuccessCallback<Location> locationUpdate) {
this.carCallback = carCallback;
locationCallback = locationUpdate;
LocationManager.getLocationManager().
setLocationListener(new LocationListener() {
@Override
LocationService (Client)
The class has a private constructor so the only way to create the LocationService is via the bind method which in turn invokes the instance method bindImpl. We provide
two callbacks one is for a car being added which we will use to bind a new car to the UI and the other is for location updates so we can position the map
5. private void bindImpl(CarAdded carCallback,
SuccessCallback<Location> locationUpdate) {
this.carCallback = carCallback;
locationCallback = locationUpdate;
LocationManager.getLocationManager().
setLocationListener(new LocationListener() {
@Override
public void locationUpdated(Location location) {
lastKnownLocation = location;
if(location.getStatus() == LocationManager.AVAILABLE &&
locationCallback != null) {
SuccessCallback<Location> c = locationCallback;
locationCallback = null;
c.onSucess(location);
}
if(server != null) {
server.sendLocationUpdate();
}
}
@Override
public void providerStateChanged(int newState) {
}
});
new SocketConnection().connect();
LocationService (Client)
Location update notifies the server about changes to the location and also invokes the callback once so we can position the map
6. private void bindImpl(CarAdded carCallback,
SuccessCallback<Location> locationUpdate) {
this.carCallback = carCallback;
locationCallback = locationUpdate;
LocationManager.getLocationManager().
setLocationListener(new LocationListener() {
@Override
public void locationUpdated(Location location) {
lastKnownLocation = location;
if(location.getStatus() == LocationManager.AVAILABLE &&
locationCallback != null) {
SuccessCallback<Location> c = locationCallback;
locationCallback = null;
c.onSucess(location);
}
if(server != null) {
server.sendLocationUpdate();
}
}
@Override
public void providerStateChanged(int newState) {
}
});
new SocketConnection().connect();
LocationService (Client)
We invoke the callback with the location so the map can be shifted to our current position
7. private void bindImpl(CarAdded carCallback,
SuccessCallback<Location> locationUpdate) {
this.carCallback = carCallback;
locationCallback = locationUpdate;
LocationManager.getLocationManager().
setLocationListener(new LocationListener() {
@Override
public void locationUpdated(Location location) {
lastKnownLocation = location;
if(location.getStatus() == LocationManager.AVAILABLE &&
locationCallback != null) {
SuccessCallback<Location> c = locationCallback;
locationCallback = null;
c.onSucess(location);
}
if(server != null) {
server.sendLocationUpdate();
}
}
@Override
public void providerStateChanged(int newState) {
}
});
new SocketConnection().connect();
LocationService (Client)
Once the server socket is connected we start sending location updates there
8. private void bindImpl(CarAdded carCallback,
SuccessCallback<Location> locationUpdate) {
this.carCallback = carCallback;
locationCallback = locationUpdate;
LocationManager.getLocationManager().
setLocationListener(new LocationListener() {
@Override
public void locationUpdated(Location location) {
lastKnownLocation = location;
if(location.getStatus() == LocationManager.AVAILABLE &&
locationCallback != null) {
SuccessCallback<Location> c = locationCallback;
locationCallback = null;
c.onSucess(location);
}
if(server != null) {
server.sendLocationUpdate();
}
}
@Override
public void providerStateChanged(int newState) {
}
});
new SocketConnection().connect();
LocationService (Client)
We open the WebSocket connection using the connect() call
9. new SocketConnection().connect();
}
class SocketConnection extends WebSocket {
private double lat, lon;
private float direction;
private long lastUpdateTime;
private EasyThread et;
public SocketConnection() {
super(Globals.SERVER_SOCKET_URL);
et = EasyThread.start("Websocket");
}
@Override
protected void onOpen() {
server = this;
sendLocationUpdate();
}
public void sendLocationUpdate() {
if(!et.isThisIt()) {
et.run(() -> sendLocationUpdate());
return;
}
if(lastKnownLocation != null) {
double lt = lastKnownLocation.getLatitude();
double ll = lastKnownLocation.getLongitude();
LocationService (Client)
We cache the last set of values so we don't send data to the server unless something changed
10. new SocketConnection().connect();
}
class SocketConnection extends WebSocket {
private double lat, lon;
private float direction;
private long lastUpdateTime;
private EasyThread et;
public SocketConnection() {
super(Globals.SERVER_SOCKET_URL);
et = EasyThread.start("Websocket");
}
@Override
protected void onOpen() {
server = this;
sendLocationUpdate();
}
public void sendLocationUpdate() {
if(!et.isThisIt()) {
et.run(() -> sendLocationUpdate());
return;
}
if(lastKnownLocation != null) {
double lt = lastKnownLocation.getLatitude();
double ll = lastKnownLocation.getLongitude();
LocationService (Client)
EasyThread lets us post "jobs" onto a dedicated thread so we don't have to block the main EDT. It also means we don't need to deal with synchronization or any other
complexity related to that as all operations happen on that thread
11. new SocketConnection().connect();
}
class SocketConnection extends WebSocket {
private double lat, lon;
private float direction;
private long lastUpdateTime;
private EasyThread et;
public SocketConnection() {
super(Globals.SERVER_SOCKET_URL);
et = EasyThread.start("Websocket");
}
@Override
protected void onOpen() {
server = this;
sendLocationUpdate();
}
public void sendLocationUpdate() {
if(!et.isThisIt()) {
et.run(() -> sendLocationUpdate());
return;
}
if(lastKnownLocation != null) {
double lt = lastKnownLocation.getLatitude();
double ll = lastKnownLocation.getLongitude();
LocationService (Client)
Until onOpen() is invoked the connection isn't ready. That's why the server member field is only initialized here when it's actually ready
12. new SocketConnection().connect();
}
class SocketConnection extends WebSocket {
private double lat, lon;
private float direction;
private long lastUpdateTime;
private EasyThread et;
public SocketConnection() {
super(Globals.SERVER_SOCKET_URL);
et = EasyThread.start("Websocket");
}
@Override
protected void onOpen() {
server = this;
sendLocationUpdate();
}
public void sendLocationUpdate() {
if(!et.isThisIt()) {
et.run(() -> sendLocationUpdate());
return;
}
if(lastKnownLocation != null) {
double lt = lastKnownLocation.getLatitude();
double ll = lastKnownLocation.getLongitude();
LocationService (Client)
If we already have a location we should send a user location update one we have the socket connection in place
13. new SocketConnection().connect();
}
class SocketConnection extends WebSocket {
private double lat, lon;
private float direction;
private long lastUpdateTime;
private EasyThread et;
public SocketConnection() {
super(Globals.SERVER_SOCKET_URL);
et = EasyThread.start("Websocket");
}
@Override
protected void onOpen() {
server = this;
sendLocationUpdate();
}
public void sendLocationUpdate() {
if(!et.isThisIt()) {
et.run(() -> sendLocationUpdate());
return;
}
if(lastKnownLocation != null) {
double lt = lastKnownLocation.getLatitude();
double ll = lastKnownLocation.getLongitude();
LocationService (Client)
The connection is single threaded as I mentioned before. The isThisIt() method is similar to isEDT() and indicates if the current thread is the one managed by the
EasyThread if not we use run(Runnable) which invokes the target Runnable on the EasyThread similarly to callSerially
14. public void sendLocationUpdate() {
if(!et.isThisIt()) {
et.run(() -> sendLocationUpdate());
return;
}
if(lastKnownLocation != null) {
double lt = lastKnownLocation.getLatitude();
double ll = lastKnownLocation.getLongitude();
float dir = lastKnownLocation.getDirection();
if(ll == lon && lt == lat && dir == direction) {
return;
}
long time = System.currentTimeMillis();
if(time - lastUpdateTime < MAX_UPDATE_FREQUENCY) {
return;
}
lastUpdateTime = time;
lon = ll;
lat = lt;
direction = dir;
try(ByteArrayOutputStream bos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(bos);) {
dos.writeShort(MESSAGE_TYPE_LOCATION_UPDATE);
String token = Preferences.get("token", null);
LocationService (Client)
If the values didn't change since last update so we do nothing
15. public void sendLocationUpdate() {
if(!et.isThisIt()) {
et.run(() -> sendLocationUpdate());
return;
}
if(lastKnownLocation != null) {
double lt = lastKnownLocation.getLatitude();
double ll = lastKnownLocation.getLongitude();
float dir = lastKnownLocation.getDirection();
if(ll == lon && lt == lat && dir == direction) {
return;
}
long time = System.currentTimeMillis();
if(time - lastUpdateTime < MAX_UPDATE_FREQUENCY) {
return;
}
lastUpdateTime = time;
lon = ll;
lat = lt;
direction = dir;
try(ByteArrayOutputStream bos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(bos);) {
dos.writeShort(MESSAGE_TYPE_LOCATION_UPDATE);
String token = Preferences.get("token", null);
LocationService (Client)
We don't update too much, there is a chance we'll miss an update here but it's probably not a deal breaker if a user didn't move much
16. public void sendLocationUpdate() {
if(!et.isThisIt()) {
et.run(() -> sendLocationUpdate());
return;
}
if(lastKnownLocation != null) {
double lt = lastKnownLocation.getLatitude();
double ll = lastKnownLocation.getLongitude();
float dir = lastKnownLocation.getDirection();
if(ll == lon && lt == lat && dir == direction) {
return;
}
long time = System.currentTimeMillis();
if(time - lastUpdateTime < MAX_UPDATE_FREQUENCY) {
return;
}
lastUpdateTime = time;
lon = ll;
lat = lt;
direction = dir;
try(ByteArrayOutputStream bos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(bos);) {
dos.writeShort(MESSAGE_TYPE_LOCATION_UPDATE);
String token = Preferences.get("token", null);
LocationService (Client)
We create a ByteArrayOutputStream into which we construct the message that we receive on the server with the header, location etc.
17. try(ByteArrayOutputStream bos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(bos);) {
dos.writeShort(MESSAGE_TYPE_LOCATION_UPDATE);
String token = Preferences.get("token", null);
dos.writeShort(token.length());
for(int iter = 0 ; iter < token.length() ; iter++) {
dos.writeByte((byte)token.charAt(iter));
}
dos.writeDouble(lat);
dos.writeDouble(lon);
dos.writeFloat(dir);
dos.writeDouble(1);
dos.writeByte(0);
dos.flush();
send(bos.toByteArray());
} catch(IOException err) {
Log.e(err);
}
}
}
@Override
protected void onClose(int i, String string) {
Log.p("Connection closed! Error... "
LocationService (Client)
I currently hardcoded a 1 kilometer search radius and defined explicitly that we aren't in taxi hailing mode
18. try(ByteArrayOutputStream bos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(bos);) {
dos.writeShort(MESSAGE_TYPE_LOCATION_UPDATE);
String token = Preferences.get("token", null);
dos.writeShort(token.length());
for(int iter = 0 ; iter < token.length() ; iter++) {
dos.writeByte((byte)token.charAt(iter));
}
dos.writeDouble(lat);
dos.writeDouble(lon);
dos.writeFloat(dir);
dos.writeDouble(1);
dos.writeByte(0);
dos.flush();
send(bos.toByteArray());
} catch(IOException err) {
Log.e(err);
}
}
}
@Override
protected void onClose(int i, String string) {
Log.p("Connection closed! Error... "
LocationService (Client)
One line to actually send the binary data, it would be similar with text data with the exception of parsing overhead. The IOException isn't likely as this is a RAM based
stream
19. try(ByteArrayOutputStream bos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(bos);) {
dos.writeShort(MESSAGE_TYPE_LOCATION_UPDATE);
String token = Preferences.get("token", null);
dos.writeShort(token.length());
for(int iter = 0 ; iter < token.length() ; iter++) {
dos.writeByte((byte)token.charAt(iter));
}
dos.writeDouble(lat);
dos.writeDouble(lon);
dos.writeFloat(dir);
dos.writeDouble(1);
dos.writeByte(0);
dos.flush();
send(bos.toByteArray());
} catch(IOException err) {
Log.e(err);
}
}
}
@Override
protected void onClose(int i, String string) {
Log.p("Connection closed! Error... "
LocationService (Client)
The IOException isn't likely as this is a RAM based stream
20. @Override
protected void onClose(int i, String string) {
Log.p("Connection closed! Error... "
+ "trying to reconnect in 5 seconds");
UITimer.timer(5000, false, () -> connect());
}
@Override
protected void onMessage(String string) {
}
@Override
protected void onMessage(byte[] bytes) {
try {
DataInputStream dis = new DataInputStream(
new ByteArrayInputStream(bytes));
short response = dis.readShort();
int size = dis.readInt();
for(int iter = 0 ; iter < size ; iter++) {
long id = dis.readLong();
User car = cars.get(id);
if(car == null) {
car = new User().
id.set(id).
latitude.set(dis.readDouble()).
longitude.set(dis.readDouble()).
LocationService (Client)
Here we receive the messages sent from the server specifically driver search results
21. @Override
protected void onClose(int i, String string) {
Log.p("Connection closed! Error... "
+ "trying to reconnect in 5 seconds");
UITimer.timer(5000, false, () -> connect());
}
@Override
protected void onMessage(String string) {
}
@Override
protected void onMessage(byte[] bytes) {
try {
DataInputStream dis = new DataInputStream(
new ByteArrayInputStream(bytes));
short response = dis.readShort();
int size = dis.readInt();
for(int iter = 0 ; iter < size ; iter++) {
long id = dis.readLong();
User car = cars.get(id);
if(car == null) {
car = new User().
id.set(id).
latitude.set(dis.readDouble()).
longitude.set(dis.readDouble()).
LocationService (Client)
We store User instances in a Map where the user ID is the key. This saves us from sending duplicate carAdded events and allows us to just mutate the User properties
which other code can observe using the builtin listeners in properties
22. long id = dis.readLong();
User car = cars.get(id);
if(car == null) {
car = new User().
id.set(id).
latitude.set(dis.readDouble()).
longitude.set(dis.readDouble()).
direction.set(dis.readFloat());
cars.put(id, car);
User finalCar = car;
callSerially(() -> carCallback.carAdded(finalCar));
} else {
car.latitude.set(dis.readDouble()).
longitude.set(dis.readDouble()).
direction.set(dis.readFloat());
}
}
} catch(IOException err) {
Log.e(err);
}
}
protected void onError(Exception e) {
Log.e(e);
}
LocationService (Client)
Notice that this code is running on the WebSocket thread so events need to go back into the EDT to prevent potential issues
23. long id = dis.readLong();
User car = cars.get(id);
if(car == null) {
car = new User().
id.set(id).
latitude.set(dis.readDouble()).
longitude.set(dis.readDouble()).
direction.set(dis.readFloat());
cars.put(id, car);
User finalCar = car;
callSerially(() -> carCallback.carAdded(finalCar));
} else {
car.latitude.set(dis.readDouble()).
longitude.set(dis.readDouble()).
direction.set(dis.readFloat());
}
}
} catch(IOException err) {
Log.e(err);
}
}
protected void onError(Exception e) {
Log.e(e);
}
LocationService (Client)
This is really important, we need handle errors properly in a WebSocket application otherwise a failure can leave us without a connection
24. latitude.set(dis.readDouble()).
longitude.set(dis.readDouble()).
direction.set(dis.readFloat());
cars.put(id, car);
User finalCar = car;
callSerially(() -> carCallback.carAdded(finalCar));
} else {
car.latitude.set(dis.readDouble()).
longitude.set(dis.readDouble()).
direction.set(dis.readFloat());
}
}
} catch(IOException err) {
Log.e(err);
}
}
protected void onError(Exception e) {
Log.e(e);
}
}
public static interface CarAdded {
void carAdded(User driver);
}
}
LocationService (Client)
The callback interface is trivial, it's mostly used as a lambda expression in the code… And that’s it for the location service…