CORS

  cors
CORS (Cross Origin Resource Sharing) is the mechanism which controls access to web resources outside of the requester’s domain. CORS access is negotiated through a preflight OPTIONS requests. An example request might look like: OPTIONS /cors/example/resource/ HTTP/1.1 ... Some irrelevant headers Origin: http://trusty.mctrusterson Access-Control-Request-Method: POST Access-Control-Request-Headers: X-Configure, Content-Type Origin refers to the domain this request originates, in the example trusty.mctrusterson. Access-Control-Request-Method is an additional security feature which the server can use to restrict access of a resource to certain methods.

Real-time Multiplayer Networking: Tick Rate and Interpolation

  games, real-time, networking
In the two previous posts, we discussed how to remedy the problems caused by an authoritative server model, but only from the perspective of a single user. We’ll now look at what happens when we introduce other players and their data. Getting Other Players’ Data Whenever any player passes input to their client, we need to send it to the server and use it to update the game state. However, our server can’t keep updating the game state every time it gets new inputs and rebroadcasting it to every client, because this would put a significant strain on the server’s resources, and consume a huge amount of bandwidth by constantly sending out new game state updates to its clients.

Real-time Multiplayer Networking: Client-Server Reconciliation

  games, real-time, networking
In the previous dump, we discussed how client-side prediction can be used to reduce lag in a real-time multiplayer application with an authoritative server. However, we saw that this can sometimes lead to a situation in which the server returns an authoritative game state to the client that, from the client’s perspective, is in the past. This drove us to figure out how we can reconcile the client’s prediction with the server’s game state (which must remain authoritative).

Real-time Multiplayer Networking: Client-side Prediction

  games, real-time, networking
When developing a multiplayer competitive game, one of the main concerns is preventing your players from cheating. Imagine you have an authoritative client, meaning that it updates the game state and sends it to the server, which assumes the clients are trustworthy and pushes their updates to the other players’ clients. With this model, a player could easily spoof a game state (I have full health and infinite ammo) and send it to the server (OK, sounds good!

Swift "namespaces"

  swift
Namespacing in source code is a way to organize named symbols together in a logical grouping. Namespacing can help to organize symbols into some sort of hierarchy. It also allows different symbols to share the same name if they are in different namespaces. In OOP code, a class definition is a natural namespace, but some languages also have a more abstract ‘namespace’ construct. C++ has a namespace keyword to denote a named scope:

Python: Slices

  python
If you work with Python often, slicing a list is something you’ve done countless times. By now you’ve probably done it so much you don’t think about it. However, I recently spent time, with a few books, digging into the standard library and I learned (or was reminded of) a couple things regarding slices. Named Slices If you need to use the same ranges over and over for slicing, you can assign them to variables creating reusable, named slices.

Systemd: The Basics

  linux
Ubuntu 16.04 is the first LTS release using the Systemd init system instead of Upstart. If you’ve done much systems development you’re probably pretty familiar with the Upstart workflow by now. Systemd is different, but the info below should help you get started. Unit Files Unit Files define services in Systemd. There are a few locations where these can be saved, but the most common is /etc/systemd/system. Files in this directory take precedence over any other Unit Files on the system.

Send APNS Push Messages with Boto3

  apns, aws
The tricky thing about sending APNS push messages via Boto3 is that you have to make sure you encode the json twice. Once for the actual payload and then for the message that’s published. In order for it to work though the MessageStructure argument must be set to 'json'. Here’s a mini example. Note(s): - APNS Payload format examples can be found here. - You definitely need an AWS account.

Reactive Programming: View Bindings

  java, android, reactive
Reactive Programming has been gaining traction in mobile development with frameworks like RxJava and RxSwift. Using it correctly can really help speed up development time and eliminate common headaches and bugs. Here we’ll go over some basics of using view bindings with RxJava and RxBinding. Say you want to watch for changes made by a user to an input field: RxView.textChanges(myTextView) .subscribe({ newText -> // Do something with newText }) In this example, every time a character is entered the lambda in “subscribe” will be called with the latest text in the input field.

Reactive Programming: Android Networking

  java, android, reactive
Reactive programming allows you to compose asynchronous actions in some pretty cool ways. A great way to show this is using network calls; RxJava will handle all of the threading and error handling for you. Using Square’s Retrofit library and RxJava, a simple HTTP request would look like this: apiClient.getUser(token) .subscribeOn(Schedulers.io()) // Thread of the network call .observeOn(AndroidSchedulers.mainThread()) // Thread of the subscribe block .subscribe({ user -> // Do something with User }, {error -> // Woops }) The error block here will handle any non 200 response from the HTTP request.